/** * Find NodeData by parent path without any dimension reduction and grouping by identifier * * Only used internally for setting the path of all child nodes * * @param string $parentPath * @param Workspace $workspace * @return array<\TYPO3\TYPO3CR\Domain\Model\NodeData> A unreduced array of NodeData */ public function findByParentWithoutReduce($parentPath, Workspace $workspace) { $parentPath = strtolower($parentPath); $workspaces = array(); while ($workspace !== null) { $workspaces[] = $workspace; $workspace = $workspace->getBaseWorkspace(); } $queryBuilder = $this->createQueryBuilder($workspaces); $this->addParentPathConstraintToQueryBuilder($queryBuilder, $parentPath); $query = $queryBuilder->getQuery(); $foundNodes = $query->getResult(); $childNodeDepth = NodePaths::getPathDepth($parentPath) + 1; /** @var $addedNode NodeData */ foreach ($this->addedNodes as $addedNode) { if ($addedNode->getDepth() === $childNodeDepth && NodePaths::getParentPath($addedNode->getPath()) === $parentPath && in_array($addedNode->getWorkspace(), $workspaces)) { $foundNodes[] = $addedNode; } } /** @var $removedNode NodeData */ foreach ($this->removedNodes as $removedNode) { if ($removedNode->getDepth() === $childNodeDepth && NodePaths::getParentPath($removedNode->getPath()) === $parentPath && in_array($removedNode->getWorkspace(), $workspaces)) { $foundNodes = array_filter($foundNodes, function ($nodeData) use($removedNode) { return $nodeData !== $removedNode; }); } } return $foundNodes; }
/** * Returns the level at which this node is located. * Counting starts with 0 for "/", 1 for "/foo", 2 for "/foo/bar" etc. * * @return integer */ public function getDepth() { if ($this->depth === null) { $this->depth = NodePaths::getPathDepth($this->path); } return $this->depth; }
/** * If the node is not found, we *first* want to figure out whether the node exists in other dimensions or is really non-existent * * @param $identifier * @param ContentContext $context * @return void */ protected function addExistingNodeVariantInformationToResponse($identifier, ContentContext $context) { $nodeVariants = $context->getNodeVariantsByIdentifier($identifier); if (count($nodeVariants) > 0) { $this->response->setHeader('X-Neos-Node-Exists-In-Other-Dimensions', true); // If the node exists in another dimension, we want to know how many nodes in the rootline are also missing for the target // dimension. This is needed in the UI to tell the user if nodes will be materialized recursively upwards in the rootline. // To find the node path for the given identifier, we just use the first result. This is a safe assumption at least for // "Document" nodes (aggregate=TRUE), because they are always moved in-sync. $node = reset($nodeVariants); /** @var NodeInterface $node */ if ($node->getNodeType()->isAggregate()) { $pathSegmentsToSites = NodePaths::getPathDepth(SiteService::SITES_ROOT_PATH); $pathSegmentsToNodeVariant = NodePaths::getPathDepth($node->getPath()); // Segments between the sites root "/sites" and the node variant (minimum 1) $pathSegments = $pathSegmentsToNodeVariant - $pathSegmentsToSites; // Nodes between (and including) the site root node and the node variant (minimum 1) $siteNodePath = NodePaths::addNodePathSegment(SiteService::SITES_ROOT_PATH, $context->getCurrentSite()->getNodeName()); $nodes = $context->getNodesOnPath($siteNodePath, $node->getPath()); $missingNodesOnRootline = $pathSegments - count($nodes); if ($missingNodesOnRootline > 0) { $this->response->setHeader('X-Neos-Nodes-Missing-On-Rootline', $missingNodesOnRootline); } } } }