Example #1
0
 /**
  * {@inheritdoc}
  */
 public function getRoutesByNames($names)
 {
     if (null !== $names && is_array($names)) {
         return $this->routeManager->findVisibleByNames($names);
     }
     return array();
 }
Example #2
0
 /**
  * Create node translation route.
  *
  * @param NodeTranslationInterface $translation
  *
  * @return RouteInterface
  */
 public function create(NodeTranslationInterface $translation)
 {
     $locale = $translation->getLang();
     $node = $translation->getNode();
     $route = $this->routeManager->create();
     $route->setRoutePattern($this->routerHelper->getRoutePattern($translation->getTitle(), $node, $locale));
     $this->routeGenerator->generateRoute($route, $node, $locale);
     $this->routeManager->add($route);
     return $route;
 }
 /**
  * Sitemap preview index action.
  *
  * @param Request $request
  *
  * @return Response
  *
  * @throws NotFoundHttpException
  */
 public function indexAction(Request $request)
 {
     $route = null;
     if (null !== ($routePattern = $request->get('route', null))) {
         $route = $this->routeManager->findByRoutePattern($routePattern);
     }
     if (null === $route) {
         throw new NotFoundHttpException(sprintf('Not found route: %s', $routePattern));
     }
     $query = array('_route_params' => array('_route_object' => $route));
     $subRequest = $request->duplicate($query, null, $route->getDefaults());
     return $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
 }
 /**
  * Reverse transform.
  *
  * @param NodeTranslationInterface $nodeTranslation
  *
  * @return NodeTranslationInterface
  */
 public function reverseTransform($nodeTranslation)
 {
     $route = $nodeTranslation->getRoute();
     if (null !== $route && $route->getRoutePattern()) {
         $node = $nodeTranslation->getNode();
         if ($this->routerHelper->hasController($node->getType())) {
             $this->routeGenerator->generateRoute($route, $node, $nodeTranslation->getLang());
             $this->routeManager->add($route);
         } else {
             $this->routeManager->remove($route);
         }
     }
     return $nodeTranslation;
 }
Example #5
0
 /**
  * Has route.
  *
  * @param string $routePattern
  * @param string $routeName
  *
  * @return bool
  *
  * @throws RoutingRuntimeException
  */
 private function hasRoute($routePattern, $routeName)
 {
     if (!$routeName) {
         throw new RoutingRuntimeException('Route name is empty!');
     }
     $route = $this->routeManager->findByRoutePattern($routePattern);
     return null !== $route && $routeName !== $route->getName();
 }
 /**
  * Reverse transform.
  *
  * @param NodeTranslationInterface $nodeTranslation
  *
  * @return NodeTranslationInterface
  */
 public function reverseTransform($nodeTranslation)
 {
     $route = $nodeTranslation->getRoute();
     if (null !== $route && $route->getRoutePattern()) {
         $node = $nodeTranslation->getNode();
         if ('redirect' === $node->getType()) {
             $this->routeGenerator->generateRoute($route, $node, $nodeTranslation->getLang());
             $this->redirectRoute->setName($route->getName());
             $route->setDefault('redirectRouteName', $this->redirectRoute->getName());
             $this->routeManager->add($route);
             $this->redirectRouteManager->add($this->redirectRoute);
         } else {
             $this->routeManager->remove($route);
             $this->redirectRouteManager->remove($this->redirectRoute);
         }
     }
     return $nodeTranslation;
 }
Example #7
0
 /**
  * Get route by pattern.
  *
  * @param string $pattern
  *
  * @return null|RouteInterface
  */
 public function getRouteByPattern($pattern)
 {
     return $this->routeManager->findByRoutePattern($pattern);
 }
Example #8
0
 /**
  * {@inheritdoc}
  */
 public function getClass()
 {
     return $this->routeManager->getClass();
 }