/** * {@inheritdoc} */ public function getRootNode() { $tree = $this->treeProvider->getTree(TadckaSitemapBundle::SITEMAP_TREE); if (null === $tree) { throw new ResourceNotFoundException(sprintf('Tree %s not found', TadckaSitemapBundle::SITEMAP_TREE)); } $rootNode = $this->nodeManager->findRootNode($tree); if (null === $rootNode) { $rootNode = $this->nodeManager->create(); $rootNode->setTree($tree); $this->nodeManager->add($rootNode); } return $rootNode; }
/** * Create node. * * @param TreeInterface $tree * @param NodeInterface $parent * * @return NodeInterface */ private function createNode(TreeInterface $tree, NodeInterface $parent) { $node = $this->nodeManager->create(); $node->setTree($tree); $node->setParent($parent); $this->nodeManager->add($node); return $node; }