diff --git a/src/Phroute/RouteCollector.php b/src/Phroute/RouteCollector.php index 59fbe88..39b55a4 100644 --- a/src/Phroute/RouteCollector.php +++ b/src/Phroute/RouteCollector.php @@ -273,6 +273,11 @@ public function controller($route, $classname, array $filters = []) $reflection = new ReflectionClass($classname); $validMethods = $this->getValidMethods(); + + if(is_array($route)) + { + list($route, $name) = $route; + } $sep = $route === '/' ? '' : '/'; @@ -288,10 +293,22 @@ public function controller($route, $classname, array $filters = []) if($methodName === self::DEFAULT_CONTROLLER_ROUTE) { - $this->addRoute($valid, $route . $params, [$classname, $method->name], $filters); + if (isset($name)) + { + $this->addRoute($valid, [$route . $params, $name], array($classname, $method->name), $filters); + } + else + { + $this->addRoute($valid, $route . $params, array($classname, $method->name), $filters); + } + } - $this->addRoute($valid, $route . $sep . $methodName . $params, [$classname, $method->name], $filters); + if (isset($name)) { + $this->addRoute($valid, [$route . $sep . $methodName . $params, $name . '-' . $methodName], array($classname, $method->name), $filters); + } else { + $this->addRoute($valid, $route . $sep . $methodName . $params, array($classname, $method->name), $filters); + } break; }