/** * Process node form. * * @param Request $request * @param FormInterface $form * * @return bool */ public function process(Request $request, FormInterface $form) { if ($request->isMethod('POST')) { $form->submit($request); if ($form->isValid()) { $this->nodeManager->add($form->getData()); return true; } } return false; }
/** * {@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; }