/**
  * @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);
     }
 }
 /**
  * @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
  * @param string        $nodeId
  *
  * @return NodeInterface
  */
 public function hydrateNodeFromNodeId(NodeInterface $node, $nodeId)
 {
     $siteId = $this->contextManager->getCurrentSiteId();
     $oldNode = $this->nodeRepository->findInLastVersion($nodeId, $node->getLanguage(), $siteId);
     if ($oldNode) {
         $node->setTemplate($oldNode->getTemplate());
         $this->duplicateBlockAndArea($oldNode, $node);
     }
     return $node;
 }
 /**
  * @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 string        $message
  * @param NodeInterface $node
  */
 protected function info($message, NodeInterface $node)
 {
     $this->logger->info($message, array('node_id' => $node->getNodeId(), 'node_version' => $node->getVersion(), 'node_language' => $node->getLanguage(), 'node_name' => $node->getName()));
 }
 /**
  * @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())));
 }