/**
  * Checks if a dynamic route pattern isn't in menu
  *
  * @param NodeInterface $value      The value that should be validated
  * @param Constraint    $constraint The constraint for the validation
  */
 public function validate($value, Constraint $constraint)
 {
     if ($value->isInMenu() || $value->isInFooter()) {
         if (preg_match('/{.*}/', $value->getRoutePattern())) {
             $this->context->buildViolation($constraint->message)->atPath('routePattern')->addViolation();
         }
     }
 }
 /**
  * Checks if the passed value is valid.
  *
  * @param NodeInterface $value The value that should be validated
  * @param Constraint    $constraint The constraint for the validation
  */
 public function validate($value, Constraint $constraint)
 {
     $nodesSameRoute = $this->nodeRepository->findByParentAndRoutePattern($value->getParentId(), $value->getRoutePattern(), $value->getNodeId(), $value->getSiteId());
     if (0 < count($nodesSameRoute)) {
         $nodesSameRoute = current($nodesSameRoute);
         $message = $constraint->message;
         if (true === $nodesSameRoute->isDeleted()) {
             $message = $constraint->messageWitNodeDeleted;
         }
         $this->context->buildViolation($message, array("%nodeName%" => $nodesSameRoute->getName()))->atPath('routePattern')->addViolation();
     }
 }
 /**
  * @param NodeInterface               $node
  * @param BlockNodePattern|Constraint $constraint
  */
 public function validate($node, Constraint $constraint)
 {
     if ($node->getStatus() instanceof StatusInterface && $node->getStatus()->isPublished()) {
         $areas = $node->getAreas();
         $routePattern = $node->getRoutePattern();
         foreach ($areas as $area) {
             $blocks = $area->getBlocks();
             foreach ($blocks as $block) {
                 $blockLabel = $block->getLabel();
                 $parameters = $this->generateFormManager->getRequiredUriParameter($block);
                 foreach ($parameters as $parameter) {
                     if (false === strpos($routePattern, '{' . $parameter . '}')) {
                         $this->context->buildViolation($constraint->message)->setParameters(array('%blockLabel%' => $blockLabel, '%parameter%' => $parameter))->atPath('routePattern')->addViolation();
                     }
                 }
             }
         }
     }
 }
 /**
  * @param ObjectManager $manager
  * @param NodeInterface $node
  */
 protected function generateRouteNode(ObjectManager $manager, $node)
 {
     $site = $this->getReference('site3');
     foreach ($site->getAliases() as $key => $alias) {
         if ($alias->getLanguage() == $node->getLanguage()) {
             $route = new RouteDocument();
             $route->setName($key . '_' . $node->getId());
             $route->setHost($alias->getDomain());
             $scheme = $alias->getScheme();
             $route->setSchemes($scheme);
             $route->setLanguage($node->getLanguage());
             $route->setNodeId($node->getNodeId());
             $route->setSiteId($site->getSiteId());
             $route->setAliasId($key);
             $route->setPattern($node->getRoutePattern());
             $manager->persist($route);
         }
     }
 }
 /**
  * @param NodeInterface $node
  */
 public function generateRedirectionForNode(NodeInterface $node)
 {
     $siteId = $node->getSiteId();
     $this->deleteRedirection($node->getNodeId(), $node->getLanguage(), $siteId);
     $nodes = $this->nodeRepository->findPublishedSortedByVersion($node->getNodeId(), $node->getLanguage(), $siteId);
     if (count($nodes) > 0) {
         $lastNode = array_shift($nodes);
         $routePatterns = array($this->completeRoutePattern($lastNode->getParentId(), $node->getRoutePattern(), $node->getLanguage()));
         foreach ($nodes as $otherNode) {
             $oldRoutePattern = $this->completeRoutePattern($otherNode->getParentId(), $otherNode->getRoutePattern(), $otherNode->getLanguage());
             if (!in_array($oldRoutePattern, $routePatterns)) {
                 $this->createRedirection($oldRoutePattern, $node->getNodeId(), $node->getLanguage());
                 array_push($routePatterns, $oldRoutePattern);
             }
         }
     }
 }
 /**
  * @param FacadeInterface $facade
  * @param NodeInterface   $node
  *
  * @return FacadeInterface
  */
 protected function addMainAttributes(FacadeInterface $facade, NodeInterface $node)
 {
     if ($site = $this->siteRepository->findOneBySiteId($node->getSiteId())) {
         $facade->templateSet = $site->getTemplateSet();
     }
     $facade->id = $node->getId();
     $facade->nodeId = $node->getNodeId();
     $facade->name = $node->getName();
     $facade->siteId = $node->getSiteId();
     $facade->deleted = $node->isDeleted();
     $facade->template = $node->getTemplate();
     $facade->nodeType = $node->getNodeType();
     $facade->parentId = $node->getParentId();
     $facade->path = $node->getPath();
     $facade->routePattern = $node->getRoutePattern();
     $facade->language = $node->getLanguage();
     $facade->metaDescription = $node->getMetaDescription();
     $facade->metaIndex = $node->getMetaIndex();
     $facade->metaFollow = $node->getMetaFollow();
     $facade->theme = $node->getTheme();
     $facade->themeSiteDefault = $node->hasDefaultSiteTheme();
     $facade->version = $node->getVersion();
     $facade->createdBy = $node->getCreatedBy();
     $facade->updatedBy = $node->getUpdatedBy();
     $facade->createdAt = $node->getCreatedAt();
     $facade->updatedAt = $node->getUpdatedAt();
     $facade->addRight('can_read', $this->authorizationChecker->isGranted(ContributionActionInterface::READ, $node));
     return $facade;
 }