コード例 #1
0
 /**
  * {@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;
 }
コード例 #2
0
 /**
  * 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;
 }