From 62e1d6fa75c23b0d15044fd37f060d1ff460ad3c Mon Sep 17 00:00:00 2001 From: sergey-nagaytsev Date: Sun, 5 Jan 2014 16:08:34 +0300 Subject: [PATCH 1/2] ADD: AltoRouter::__construct Can create in one call from config --- AltoRouter.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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. From 93e4e4f07e51fd375d23e649a06e010651a7ff5c Mon Sep 17 00:00:00 2001 From: sergey-nagaytsev Date: Tue, 7 Jan 2014 13:15:53 +0300 Subject: [PATCH 2/2] CHG: no Hungarian notation, $arRoute -> $routes --- AltoRouter.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AltoRouter.php b/AltoRouter.php index 738f686..7e3acac 100644 --- a/AltoRouter.php +++ b/AltoRouter.php @@ -9,12 +9,12 @@ class AltoRouter { /** * Create router in one call from config. * - * @param array $arRoute + * @param array $routes * @param string $basePath */ - public function __construct( $arRoute = array(), $basePath = '' ) { + public function __construct( $routes = array(), $basePath = '' ) { $this->basePath = $basePath; - foreach( $arRoute as $route ) { + foreach( $routes as $route ) { call_user_func_array(array($this,'map'),$route); } }