diff options
author | Arnold Daniels <arnold@jasny.net> | 2016-06-20 22:26:12 +0200 |
---|---|---|
committer | Arnold Daniels <arnold@jasny.net> | 2016-06-20 22:26:12 +0200 |
commit | e41ac80a66cc27a49f513aaa7c6029a1b054ee45 (patch) | |
tree | c77836442106d2cd62f4b8f732fa45e4971f5b3a | |
parent | 99482b1782f962d1ba26e9d6445b0f1ecc582070 (diff) | |
download | router-e41ac80a66cc27a49f513aaa7c6029a1b054ee45.zip router-e41ac80a66cc27a49f513aaa7c6029a1b054ee45.tar.gz router-e41ac80a66cc27a49f513aaa7c6029a1b054ee45.tar.bz2 |
Fix routing to a method
Make Router::routeTo public
-rw-r--r-- | src/Router.php | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Router.php b/src/Router.php index 34228b2..5f79e6f 100644 --- a/src/Router.php +++ b/src/Router.php @@ -311,7 +311,7 @@ class Router * @param object $overwrite * @return boolean|mixed Whatever the controller returns or true on success */ - protected function routeTo($route, $overwrite=[]) + public function routeTo($route, $overwrite=[]) { if (!is_object($route)) { $match = $this->findRoute(null, $route); @@ -374,6 +374,8 @@ class Router if (isset($route->args)) { $args = $route->args; + } elseif (is_array($route->fn)) { + $args = static::getFunctionArgs($route, new \ReflectionMethod($route->fn[0], $route->fn[1])); } elseif (function_exists($route->fn)) { $args = static::getFunctionArgs($route, new \ReflectionFunction($route->fn)); } @@ -561,7 +563,9 @@ class Router foreach ($vars as $key=>$var) { if (!isset($var)) continue; - if (!is_scalar($var)) { + if (is_object($var) && !$var instanceof \stdClass) { + $part = array($var); + } elseif (!is_scalar($var)) { $part = array(static::bind($var, $parts)); } elseif ($var[0] === '$') { $options = array_map('trim', explode('|', $var)); |