/**
  * @param NodeInterface $node
  */
 protected function deleteRedirectionForNodeTree(NodeInterface $node)
 {
     $this->redirectionManager->deleteRedirection($node->getNodeId(), $node->getLanguage(), $node->getSiteId());
     $nodes = $this->nodeRepository->findByParent($node->getNodeId(), $node->getSiteId());
     foreach ($nodes as $node) {
         $this->deleteRedirectionForNodeTree($node);
     }
 }
 /**
  * Checks if the passed value is valid.
  *
  * @param NodeInterface $value      The value that should be validated
  * @param Constraint    $constraint The constraint for the validation
  *
  * @api
  */
 public function validate($value, Constraint $constraint)
 {
     $result = $this->repository->hasOtherNodeWithSameParentAndOrder($value->getParentId(), $value->getOrder(), $value->getNodeId(), $value->getSiteId());
     if (true === $result) {
         $this->context->buildViolation($constraint->message)->addViolation();
     }
 }
 /**
  * @param NodeInterface $node
  */
 public function restore($node)
 {
     $nodes = $this->nodeRepository->findByNodeAndSite($node->getNodeId(), $node->getSiteId());
     /** @var NodeInterface $node */
     foreach ($nodes as $node) {
         $node->setDeleted(false);
     }
     $this->eventDispatcher->dispatch(NodeEvents::NODE_RESTORE, new NodeEvent($node));
 }
 /**
  * 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
  */
 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 addPreviewLinks(FacadeInterface $facade, NodeInterface $node)
 {
     if ($this->hasGroup(CMSGroupContext::PREVIEW) && ($site = $this->siteRepository->findOneBySiteId($node->getSiteId()))) {
         /** @var SiteAliasInterface $alias */
         $encryptedId = $this->encrypter->encrypt($node->getId());
         foreach ($site->getAliases() as $aliasId => $alias) {
             if ($alias->getLanguage() == $node->getLanguage()) {
                 $facade->addPreviewLink($this->getPreviewLink($node->getScheme(), $alias, $encryptedId, $aliasId));
             }
         }
     }
     return $facade;
 }
 /**
  * @param FacadeInterface $facade
  * @param NodeInterface   $node
  * @param AreaInterface   $area
  * @param string          $areaId
  */
 protected function addLinksFromNode(FacadeInterface $facade, NodeInterface $node, AreaInterface $area, $areaId)
 {
     $facade->addLink('_block_list', $this->generateRoute('open_orchestra_api_block_list_with_transverse', array('language' => $node->getLanguage())));
     $facade->addLink('_self_update_block_position', $this->generateRoute('open_orchestra_api_area_update_block_position', array('nodeId' => $node->getNodeId(), 'language' => $node->getLanguage(), 'version' => $node->getVersion(), 'siteId' => $node->getSiteId())));
 }