diff --git a/AltoRouter.php b/AltoRouter.php index 9f698f5..738f686 100644 --- a/AltoRouter.php +++ b/AltoRouter.php @@ -6,6 +6,19 @@ class AltoRouter { protected $namedRoutes = array(); protected $basePath = ''; + /** + * Create router in one call from config. + * + * @param array $arRoute + * @param string $basePath + */ + public function __construct( $arRoute = array(), $basePath = '' ) { + $this->basePath = $basePath; + foreach( $arRoute as $route ) { + call_user_func_array(array($this,'map'),$route); + } + } + /** * Set the base path. * Useful if you are running your application from a subdirectory.