/** * Returns a node specified by the given absolute path. * * @param string $path Absolute path specifying the node * @return \TYPO3\TYPO3CR\Domain\Model\NodeInterface The specified node or NULL if no such node exists * @throws \InvalidArgumentException * @api */ public function getNode($path) { if (!is_string($path) || $path[0] !== '/') { throw new \InvalidArgumentException('Only absolute paths are allowed for Context::getNode()', 1284975105); } $workspaceRootNode = $this->getWorkspace()->getRootNodeData(); $rootNode = $this->nodeFactory->createFromNodeData($workspaceRootNode, $this); if ($path !== '/') { $node = $this->firstLevelNodeCache->getByPath($path); if ($node === FALSE) { $node = $rootNode->getNode(substr($path, 1)); $this->firstLevelNodeCache->setByPath($path, $node); } } else { $node = $rootNode; } return $node; }
/** * Finds all nodes lying on the path specified by (and including) the given * starting point and end point. * * @param mixed $startingPoint Either an absolute path or an actual node specifying the starting point, for example /sites/mysitecom * @param mixed $endPoint Either an absolute path or an actual node specifying the end point, for example /sites/mysitecom/homepage/subpage * @return array<\TYPO3\TYPO3CR\Domain\Model\NodeInterface> The nodes found between and including the given paths or an empty array of none were found * @api */ public function getNodesOnPath($startingPoint, $endPoint) { $startingPointPath = $startingPoint instanceof NodeInterface ? $startingPoint->getPath() : $startingPoint; $endPointPath = $endPoint instanceof NodeInterface ? $endPoint->getPath() : $endPoint; $nodeDataElements = $this->nodeDataRepository->findOnPath($startingPointPath, $endPointPath, $this->getWorkspace(), $this->getDimensions(), $this->isRemovedContentShown()); $nodes = array(); foreach ($nodeDataElements as $nodeData) { $node = $this->nodeFactory->createFromNodeData($nodeData, $this); if ($node !== null) { $nodes[] = $node; $this->firstLevelNodeCache->setByPath($node->getPath(), $node); } } return $nodes; }