/**
  * 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 #2
0
 /**
  * {@inheritdoc}
  */
 public function remove(RouteInterface $route, $save = false)
 {
     if (isset($this->routes[$route->getName()])) {
         unset($this->routes[$route->getName()]);
     }
     $this->routeManager->remove($route, $save);
 }
 /**
  * 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;
 }