Пример #1
0
 /**
  * {@inheritdoc}
  **/
 public function setChildOf(NodeInterface $node)
 {
     $id = $this->getId();
     if (empty($id)) {
         throw new \LogicException('You must provide an id for this node if you want it to be part of a tree.');
     }
     $path = rtrim($node->getRealMaterializedPath(), static::getMaterializedPathSeparator());
     $this->setMaterializedPath($path);
     if (null !== $this->parentNode) {
         $this->parentNode->getChildren()->removeElement($this);
     }
     $this->parentNode = $node;
     $this->parentNode->addChild($this);
     foreach ($this->getChildren() as $child) {
         $child->setChildOf($this);
     }
     return $this;
 }
Пример #2
0
 public function getTreeExceptNodeAndItsChildrenQB(NodeInterface $entity, $rootAlias = 't')
 {
     return $this->getFlatTreeQB('', $rootAlias)->andWhere($rootAlias . '.materializedPath NOT LIKE :except_path')->andWhere($rootAlias . '.id != :id')->setParameter('except_path', $entity->getRealMaterializedPath() . '%')->setParameter('id', $entity->getId());
 }
Пример #3
0
 /**
  * @dataProvider provideisChildNodeOf
  **/
 public function testisChildNodeOf(NodeInterface $child, NodeInterface $parent, $expected)
 {
     $this->assertEquals($expected, $child->isChildNodeOf($parent));
 }