/**
  * Output the dump of the whole node tree
  * @TODO doesn't take into account nodes from the doctrine repo array helper
  * @return string
  */
 public function drawTree()
 {
     $searchCondition = $this->createSearchCondition();
     $orderRule = $this->createSelectOrderRule()->byLeftAscending();
     $nodes = $this->search($searchCondition, $orderRule);
     $output = Node\NodeAbstraction::output($nodes);
     return $output;
 }
示例#2
0
 /**
  * Pass the doctrine entity the nested set node belongs to
  * @param NodeInterface $entity
  */
 public function belongsTo(NodeInterface $node)
 {
     parent::belongsTo($node);
     $rep = $this->sourceRepository;
     if (!$rep instanceof RepositoryInterface) {
         throw new Exception\WrongInstance($rep, 'RepositoryInterface');
     }
     $nestedSetRepository = $rep->getNestedSetRepository();
     /* @var $nestedSetRepository DoctrineRepository */
     $this->setRepository($nestedSetRepository);
     if ($this->right === null) {
         $nestedSetRepository->add($node);
     }
     $nestedSetRepository->register($node);
 }