コード例 #1
0
 /**
  * Check if node parent is online.
  *
  * @param NodeInterface $node
  * @param string $locale
  *
  * @return bool
  */
 private function parentIsOnline(NodeInterface $node, $locale)
 {
     $parent = $node->getParent();
     if (null !== $parent && $this->routeHelper->hasController($parent->getType())) {
         if (false === $this->routeHelper->hasRoute($locale, $node)) {
             return false;
         }
         if (null === ($translation = $parent->getTranslation($locale))) {
             return false;
         }
         if (null === ($route = $translation->getRoute())) {
             return false;
         }
         return $route->isVisible();
     }
     return true;
 }
コード例 #2
0
 /**
  * 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()));
     }
 }