/**
  * Checks if the passed node is valid.
  *
  * @param NodeTranslationInterface $nodeTranslation
  * @param Constraint|NodeParentIsOnline $constraint
  */
 public function validate($nodeTranslation, Constraint $constraint)
 {
     $route = $nodeTranslation->getRoute();
     $parentIsOnline = $this->parentIsOnline($nodeTranslation->getNode(), $nodeTranslation->getLang());
     if (null !== $route && $route->isVisible() && false === $parentIsOnline) {
         $this->context->addViolation($constraint->message, array('%locale%' => $nodeTranslation->getLang()));
     }
 }
Пример #2
0
 /**
  * Create node translation seo metadata.
  *
  * @param NodeTranslationInterface $translation
  *
  * @return SeoMetadataInterface
  */
 public function create(NodeTranslationInterface $translation)
 {
     $seoMetadata = $this->seoMetadataManager->create();
     $seoMetadata->setLang($translation->getLang());
     $seoMetadata->setTitle($translation->getTitle());
     $this->seoMetadataManager->add($seoMetadata);
     return $seoMetadata;
 }
Пример #3
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;
 }
 /**
  * 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;
 }
 /**
  * Checks if the passed node is valid.
  *
  * @param NodeTranslationInterface $nodeTranslation
  * @param Constraint|NodeRouteNotEmpty $constraint
  */
 public function validate($nodeTranslation, Constraint $constraint)
 {
     if (false === $this->routeHelper->hasRoute($nodeTranslation->getLang(), $nodeTranslation->getNode())) {
         $this->context->addViolation($constraint->message, array('%locale%' => $nodeTranslation->getLang()));
     }
 }
 /**
  * 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;
 }