예제 #1
0
 /**
  * Sets state of $page and is descendant to STATE_DELETED.
  *
  * @param  Page                 $page               The page to delete.
  *
  * @return integer                                  The number of page having their state changed.
  */
 public function toTrash(Page $page)
 {
     if (true === $page->isLeaf()) {
         $page->setState(Page::STATE_DELETED);
         $this->getEntityManager()->flush($page);
         return 1;
     }
     $subquery = $this->getEntityManager()->getRepository('BackBee\\CoreDomain\\NestedNode\\Section')->createQueryBuilder('n')->select('n._uid')->andIsDescendantOf($page->getSection());
     return $this->createQueryBuilder('p')->update()->set('p._state', Page::STATE_DELETED)->andWhere('p._section IN (' . $subquery->getDQL() . ')')->setParameters($subquery->getParameters())->getQuery()->execute();
 }