/** * Converts annotation into ZF2 route config item. * * @param Route $annotation * @return array */ protected function getRouteConfig(Route $annotation) { return [$annotation->getName() => ['type' => $annotation->getType(), 'options' => ['route' => $annotation->getRoute(), 'defaults' => $annotation->getDefaults(), 'constraints' => $annotation->getConstraints()], 'priority' => (int) $annotation->getPriority(), 'may_terminate' => (bool) $annotation->getMayTerminate(), 'child_routes' => []]]; }
protected function guessMissingFields(Route $annotation, $method, $controllerClass) { if ($method instanceof MethodScanner) { $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()) { if (preg_match('/:[\\w\\d]+/', $annotation->getRoute())) { $annotation->setType('segment'); } else { $annotation->setType('literal'); } } if (!$annotation->hasDefaultController()) { if (isset($this->controllerCache[$controllerClass])) { $controllerClass = $this->controllerCache[$controllerClass]; } $annotation->setDefaultController($controllerClass); } if (!$annotation->hasDefaultAction()) { $annotation->setDefaultAction($this->filterActionMethodName($methodName)); } if (!$annotation->hasRoute()) { $annotation->setRoute('/' . $this->filterActionMethodName($methodName)); } return $annotation; }