/** * Add a route. * * @param Route $annotation * @return RouteConfigBuilder */ public function addPart(Route $annotation) { if ($annotation instanceof Container) { $this->parts = array_merge($this->parts, $annotation->getChildren()); } else { $this->parts[] = $annotation; } return $this; }
/** * Tries to guess default values for route if there some missing ones. * * @param Route $annotation * @param MethodReflection $method * @param string $controllerKey * @return Route * @throws Exception */ public function autodetectMissingFields(Route $annotation, $method, $controllerKey) { if ($method instanceof MethodReflection) { $methodName = $method->getName(); } else { if (is_string($method)) { $methodName = $method; } else { throw new Exception('Method must be a string or instance of MethodReflection'); } } if (!$annotation->hasName()) { $annotation->setName($this->filterActionMethodName($methodName)); } if (!$annotation->hasType()) { $annotation->setType('literal'); } if (!$annotation->hasDefaultController()) { $annotation->setDefaultController($controllerKey); } if (!$annotation->hasDefaultAction()) { $annotation->setDefaultAction($this->filterActionMethodName($methodName)); } if (!$annotation->hasRoute()) { $annotation->setRoute('/' . $this->filterActionMethodName($methodName)); } return $annotation; }