/**
  * Set visible route.
  *
  * @param string $locale
  * @param NodeInterface $node
  */
 public function setVisible($locale, NodeInterface $node)
 {
     $translation = $node->getTranslation($locale);
     if (null !== $translation && null !== ($route = $translation->getRoute())) {
         $route->setVisible(true);
     }
 }
Пример #2
0
 /**
  * Process node online.
  *
  * @param string $locale
  * @param Messages $messages
  * @param NodeInterface $node
  *
  * @return bool
  */
 public function process($locale, Messages $messages, NodeInterface $node)
 {
     if (null === ($nodeTranslation = $node->getTranslation($locale))) {
         $messages->addError($this->translator->trans('node_translation_not_found', array('%locale%' => $locale), 'TadckaSitemapBundle'));
         return false;
     }
     $constraints = array(new NodeRouteNotEmpty(), new NodeParentIsOnline());
     $violation = $this->validator->validateValue($nodeTranslation, $constraints);
     if (0 < $violation->count()) {
         foreach ($violation as $value) {
             $messages->addError($value->getMessage());
         }
         return false;
     }
     if (null !== ($route = $nodeTranslation->getRoute())) {
         if ($route->isVisible()) {
             $this->visibilityManager->setInvisible($locale, $node);
         } else {
             $this->visibilityManager->setVisible($locale, $node);
         }
     }
     return true;
 }
Пример #3
0
 /**
  * Get route full path.
  *
  * @param NodeInterface $node
  * @param string $locale
  *
  * @return string
  */
 private function getRouteFullPath(NodeInterface $node, $locale)
 {
     $path = '';
     if ($this->hasController($node->getType())) {
         $parent = $node->getParent();
         if (null !== $parent && $this->hasController($parent->getType())) {
             $path = $this->getRouteFullPath($parent, $locale);
         }
         if (null !== ($translation = $node->getTranslation($locale))) {
             $path .= $this->normalizeRoutePattern($translation->getTitle());
         }
     }
     return $path;
 }
Пример #4
0
 /**
  * Get node title.
  *
  * @param NodeInterface $node
  * @param string $locale
  *
  * @return string
  */
 private function getTitle(NodeInterface $node, $locale)
 {
     if (null === $node->getParent() && null === $node->getTranslation($locale)) {
         return $this->getRootNodeTitle();
     }
     $translation = $node->getTranslation($locale);
     if (null !== $translation && ($title = trim($translation->getTitle()))) {
         return $title;
     }
     return $this->translator->trans('not_found_title', array(), 'TadckaSitemapBundle');
 }
Пример #5
0
 /**
  * Get node title.
  *
  * @param string $locale
  * @param NodeInterface $node
  *
  * @return string
  */
 private function getNodeTitle($locale, NodeInterface $node)
 {
     if (null !== ($translation = $node->getTranslation($locale))) {
         return $translation->getTitle();
     }
     return $this->translator->trans('not_found_title', array(), 'TadckaSitemapBundle');
 }