Example #1
0
 /**
  * Sets state of $page and is descendant to STATE_DELETED.
  *
  * @param  Page                 $page               The page to delete.
  *
  * @return Page                                     The instance of Page entity.
  */
 public function toTrash(Page $page)
 {
     $page->setState(Page::STATE_DELETED);
     if (!$page->isLeaf()) {
         $subquery = $this->getEntityManager()->getRepository('BackBee\\NestedNode\\Section')->createQueryBuilder('n')->select('n._uid')->andIsDescendantOf($page->getSection());
         $this->createQueryBuilder('p')->update()->set('p._state', Page::STATE_DELETED)->andWhere('p._section IN (' . $subquery->getDQL() . ')')->setParameters($subquery->getParameters())->getQuery()->execute();
     }
     return $page;
 }
Example #2
0
 /**
  * @covers BackBee\NestedNode\Page::isLeaf()
  */
 public function testIsLeaf()
 {
     $this->assertFalse($this->page->isLeaf());
     $child = new Page('child');
     $child->setSection($this->page->getSection());
     $this->assertTrue($child->isLeaf());
 }