/** * 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(); }
/** * * @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); }