Ejemplo n.º 1
0
 /**
  * @param AbstractRoute $route
  */
 private function addToRouteResultMapping(AbstractRoute $route)
 {
     if ($route instanceof FinalRoute) {
         $this->resultToRouteMapping[$route->getResult()] = $route;
         return;
     }
     if ($route instanceof RouteGroup) {
         foreach ($route->getRoutes() as $childRoute) {
             $this->addToRouteResultMapping($childRoute);
         }
         return;
     }
     throw new \InvalidArgumentException('Route type should be "' . FinalRoute::class . '" or "' . RouteGroup::class . '"');
 }
Ejemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function build(Url $url, UrlBuilder $urlBuilder)
 {
     if (!empty($this->parentRoute)) {
         $this->parentRoute->build($url, $urlBuilder);
     }
     if (!empty($this->urlTemplate)) {
         $this->urlTemplate->build($url, $urlBuilder);
     }
 }
Ejemplo n.º 3
0
 /**
  * @param AbstractRoute $route
  */
 protected function storeRouteParameters(AbstractRoute $route)
 {
     foreach ($route->getDefaultParameters() as $key => $value) {
         $this->setParameter($key, $value);
     }
     foreach ($route->getModifiers() as $modifier) {
         foreach ($modifier->getDefaultParameters() as $key => $value) {
             $this->setParameter($key, $value);
         }
     }
     if ($urlTemplate = $route->getUrlTemplate()) {
         foreach ($urlTemplate->getDefaultParameters() as $key => $value) {
             $this->setParameter($key, $value);
         }
     }
     if ($parentRoute = $route->getParentRoute()) {
         $this->storeRouteParameters($parentRoute);
     }
 }
Ejemplo n.º 4
0
 /**
  * @param AbstractRoute $route
  * @return $this
  */
 public function addRoute(AbstractRoute $route)
 {
     $this->routes[] = $route;
     $route->setParentRoute($this);
     return $this;
 }
Ejemplo n.º 5
0
 /**
  * @inheritdoc
  */
 public function build(Url $url, UrlBuilder $urlBuilder)
 {
     parent::build($url, $urlBuilder);
     $this->buildModifiers($url, $urlBuilder);
 }