diff options
author | Arnold Daniels <arnold@jasny.net> | 2013-09-13 16:12:17 +0200 |
---|---|---|
committer | Arnold Daniels <arnold@jasny.net> | 2013-09-13 16:12:17 +0200 |
commit | c22c91415d00c593b3e8f1ab661b5c1640daaf97 (patch) | |
tree | 659f7bbe48153f6f06cdd39e24b3d29175d3ff09 | |
parent | 06514aab0d1ff725335d4ba5b1f71fefb5654ad8 (diff) | |
download | router-c22c91415d00c593b3e8f1ab661b5c1640daaf97.zip router-c22c91415d00c593b3e8f1ab661b5c1640daaf97.tar.gz router-c22c91415d00c593b3e8f1ab661b5c1640daaf97.tar.bz2 |
Make sure the routes are initialised before use
-rw-r--r-- | src/Jasny/Router.php | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/Jasny/Router.php b/src/Jasny/Router.php index 6da1738..091cd99 100644 --- a/src/Jasny/Router.php +++ b/src/Jasny/Router.php @@ -164,6 +164,8 @@ class Router */ protected static function findRoute($url) { + static::getRoutes(); // Make sure the routes are initialised + if ($url !== '/') $url = rtrim($url, '/'); foreach (array_keys((array)static::$routes) as $route) { @@ -223,9 +225,9 @@ class Router protected static function routeTo($route, $overwrite=[]) { if (!is_object($route)) { - $key = static::findRoute($route); - if (!isset($key) || !isset(static::$routes->$key)) return false; - $route = static::$routes->$key; + $match = static::findRoute($route); + if (!isset($match) || !isset(static::$routes->$match)) return false; + $route = static::$routes->$match; } foreach ($overwrite as $key=>$value) { |