Author: Adam Piotrowski (adam@wellcommerce.org)
 /**
  * Returns a concatenated path
  *
  * @param RouteInterface $resource
  *
  * @return string
  */
 protected function getPath(RouteInterface $resource) : string
 {
     if (strlen($this->pattern)) {
         return $resource->getPath() . RouteGeneratorInterface::PATH_PARAMS_SEPARATOR . $this->pattern;
     }
     return $resource->getPath();
 }
 /**
  * {@inheritdoc}
  */
 public function generate(RouteInterface $resource)
 {
     $this->defaults['id'] = $resource->getIdentifier()->getId();
     $this->defaults['_locale'] = $resource->getLocale();
     return new SymfonyRoute($resource->getPath(), $this->defaults, $this->requirements, $this->options);
 }
Example #3
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;
 }
 /**
  * @param RouteInterface $route
  *
  * @return string
  */
 private function generatePath(RouteInterface $route)
 {
     return $this->routerHelper->generateUrl('dynamic_' . $route->getId());
 }
 /**
  * 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;
 }
Example #6
0
 /**
  * Creates a route
  *
  * @param RouteInterface $resource
  *
  * @return null|SymfonyRoute
  */
 private function createRoute(RouteInterface $resource)
 {
     $route = null;
     /**
      * @var \WellCommerce\Bundle\RoutingBundle\Generator\RouteGeneratorInterface $generator
      */
     foreach ($this->generators 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;
 }
 /**
  * Returns a concatenated path
  *
  * @param RouteInterface $resource
  * @param string         $pattern
  *
  * @return string
  */
 private function getPath(RouteInterface $resource, string $pattern) : string
 {
     if (strlen($pattern)) {
         return $resource->getPath() . self::PATH_PARAMS_SEPARATOR . $pattern;
     }
     return $resource->getPath();
 }
 /**
  * Checks passed identifier and locale against those in route
  *
  * @param RouteInterface $route
  * @param                $locale
  * @param                $id
  *
  * @return bool
  */
 private function hasRouteSameLocaleAndId(RouteInterface $route, string $locale, $id) : bool
 {
     return $route->getIdentifier()->getId() === $id && $route->getLocale() === $locale;
 }