/** * Let the visitor visit the ancestors from root node according to mapper * down to the parent of the node identified by url * * @param string $url the url (without eventual prefix from routing config) * @param ItemVisitorInterface $visitor the visitor to look at the nodes */ public function visitAncestors($url, ItemVisitorInterface $visitor) { $node = $this->session->getNode($this->mapper->getStorageId($url)); $i = $this->rootnode->getDepth(); while (($ancestor = $node->getAncestor($i++)) != $node) { $ancestor->accept($visitor); } }
/** * @param DocumentManager $document_manager the phpcr-odm document manager to load navigation entry documents * @param \PHPCR\SessionInterface $session the phpcr session. TODO: remove when all annotations work * @param PathMapperInterface $mapper to map urls to storage ids */ public function __construct(DocumentManager $document_manager, SessionInterface $session, PathMapperInterface $mapper) { $this->odm = $document_manager; $this->session = $session; $this->mapper = $mapper; $basepath = $mapper->getStorageId('/'); $this->rootnode = $this->session->getNode($basepath); if ($this->rootnode == null) { throw new Exception("Did not find any node at {$basepath}"); } }