Ejemplo n.º 1
0
 /**
  * Returns a concatenated path
  *
  * @param RouteInterface $resource
  *
  * @return string
  */
 protected function getPath(RouteInterface $resource)
 {
     if (strlen($this->pattern)) {
         return $resource->getPath() . RouteGeneratorInterface::PATH_PARAMS_SEPARATOR . $this->pattern;
     }
     return $resource->getPath();
 }
Ejemplo n.º 2
0
 /**
  * Checks passed identifier and locale against those in route
  *
  * @param RouteInterface $route
  * @param                $locale
  * @param                $id
  *
  * @return bool
  */
 protected function hasRouteSameLocaleAndId(RouteInterface $route, $locale, $id)
 {
     return $route->getIdentifier()->getId() === $id && $route->getLocale() === $locale;
 }
Ejemplo n.º 3
0
 public function generate(RouteInterface $resource)
 {
     $this->defaults['id'] = $resource->getIdentifier()->getId();
     $this->defaults['_locale'] = $resource->getLocale();
     return new SymfonyRoute($this->getPath($resource), $this->defaults, $this->requirements, $this->options);
 }
Ejemplo n.º 4
0
 /**
  * Creates a route
  *
  * @param RouteInterface $resource
  *
  * @return null|SymfonyRoute
  */
 private function createRoute(RouteInterface $resource)
 {
     $route = null;
     foreach ($this->generators->all() as $generator) {
         if ($generator->supports($resource->getType())) {
             $route = $generator->generate($resource);
             break;
         }
     }
     if (null === $route) {
         throw new RouteNotFoundException(sprintf('No possible generator found for route "%s"', $resource->getId()));
     }
     return $route;
 }