1
0
mirror of https://github.com/dannyvankooten/AltoRouter.git synced 2025-08-07 00:46:51 +02:00

Merge pull request #44 from sergey-nagaytsev/patch-1

Create routes and set basePath from constructor call. Thank you Sergey.
This commit is contained in:
Danny van Kooten
2014-01-07 03:14:36 -08:00

View File

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