/**
  * @return array
  */
 public function buildItems()
 {
     $output = array();
     $dimension = $this->getDimension();
     foreach ($this->getPresetsInCorrectOrder() as $presetName => $presetConfiguration) {
         $q = new FlowQuery(array($this->currentNode));
         $nodeInOtherDimension = $q->context(array('dimensions' => array($dimension => $presetConfiguration['values']), 'targetDimensions' => array($dimension => reset($presetConfiguration['values']))))->get(0);
         if ($nodeInOtherDimension !== NULL && $this->isNodeHidden($nodeInOtherDimension)) {
             $nodeInOtherDimension = NULL;
         }
         $item = array('node' => $nodeInOtherDimension, 'state' => $this->calculateItemState($nodeInOtherDimension), 'label' => $presetConfiguration['label'], 'presetName' => $presetName, 'preset' => $presetConfiguration);
         $output[] = $item;
     }
     return $output;
 }
 /**
  * Generate missing URI path segments
  *
  * This generates URI path segment properties for all document nodes which don't have
  * a path segment set yet.
  *
  * @param string $workspaceName
  * @param boolean $dryRun
  * @return void
  */
 public function generateUriPathSegments($workspaceName, $dryRun)
 {
     $baseContext = $this->createContext($workspaceName, []);
     $baseContextSiteNodes = $baseContext->getNode('/sites')->getChildNodes();
     if ($baseContextSiteNodes === []) {
         return;
     }
     foreach ($this->dimensionCombinator->getAllAllowedCombinations() as $dimensionCombination) {
         $flowQuery = new FlowQuery($baseContextSiteNodes);
         $siteNodes = $flowQuery->context(['dimensions' => $dimensionCombination, 'targetDimensions' => []])->get();
         if (count($siteNodes) > 0) {
             $this->output->outputLine('Searching for nodes with missing URI path segment in dimension "%s"', array(trim(NodePaths::generateContextPath('', '', $dimensionCombination), '@;')));
             foreach ($siteNodes as $siteNode) {
                 $this->generateUriPathSegmentsForNode($siteNode, $dryRun);
             }
         }
     }
 }
 /**
  *
  * @param string $workspaceName
  * @return NodeInterface
  */
 protected function getLastVisitedNode($workspaceName)
 {
     if (!$this->session->isStarted() || !$this->session->hasKey('lastVisitedNode')) {
         return null;
     }
     try {
         $lastVisitedNode = $this->propertyMapper->convert($this->session->getData('lastVisitedNode'), NodeInterface::class);
         $q = new FlowQuery([$lastVisitedNode]);
         $lastVisitedNodeUserWorkspace = $q->context(['workspaceName' => $workspaceName])->get(0);
         return $lastVisitedNodeUserWorkspace;
     } catch (\Exception $exception) {
         return null;
     }
 }
 /**
  * Get the current node in the given dimensions.
  * If it doesn't exist the method returns null.
  *
  * @param array $dimensions
  * @param array $targetDimensions
  * @return NodeInterface|null
  */
 protected function getNodeInDimensions(array $dimensions, array $targetDimensions)
 {
     $q = new FlowQuery([$this->currentNode]);
     return $q->context(['dimensions' => $dimensions, 'targetDimensions' => $targetDimensions])->get(0);
 }
 /**
  * Generate missing URI path segments
  *
  * This generates URI path segment properties for all document nodes which don't have
  * a path segment set yet.
  *
  * @param string $workspaceName
  * @param boolean $dryRun
  * @return void
  */
 public function generateUriPathSegments($workspaceName, $dryRun)
 {
     $baseContext = $this->createContext($workspaceName, []);
     $baseContextSitesNode = $baseContext->getNode(SiteService::SITES_ROOT_PATH);
     if (!$baseContextSitesNode) {
         $this->output->outputLine('<error>Could not find "' . SiteService::SITES_ROOT_PATH . '" root node</error>');
         return;
     }
     $baseContextSiteNodes = $baseContextSitesNode->getChildNodes();
     if ($baseContextSiteNodes === []) {
         $this->output->outputLine('<error>Could not find any site nodes in "' . SiteService::SITES_ROOT_PATH . '" root node</error>');
         return;
     }
     foreach ($this->dimensionCombinator->getAllAllowedCombinations() as $dimensionCombination) {
         $flowQuery = new FlowQuery($baseContextSiteNodes);
         $siteNodes = $flowQuery->context(['dimensions' => $dimensionCombination, 'targetDimensions' => []])->get();
         if (count($siteNodes) > 0) {
             $this->output->outputLine('Checking for nodes with missing URI path segment in dimension "%s"', array(trim(NodePaths::generateContextPath('', '', $dimensionCombination), '@;')));
             foreach ($siteNodes as $siteNode) {
                 $this->generateUriPathSegmentsForNode($siteNode, $dryRun);
             }
         }
     }
     $this->persistenceManager->persistAll();
 }