public function setSectionHasChildren(Section $section = null, $pageCountModifier = 0) { if ($section !== null) { $repo = $this->entityManager->getRepository('BackBee\\CoreDomain\\NestedNode\\Page'); $notDeletedDescendants = $repo->getNotDeletedDescendants($section->getPage(), 1, false, [], true, 0, 2); $section->setHasChildren($notDeletedDescendants->getIterator()->count() + $pageCountModifier > 0); $this->entityManager->getUnitOfWork()->recomputeSingleEntityChangeSet($this->entityManager->getClassMetadata('BackBee\\CoreDomain\\NestedNode\\Section'), $section); } }
/** * Sets the section for this page. * * @param Section $section * * @return Page */ public function setSection(Section $section) { if ($section !== $this->_mainsection) { $this->_mainsection = null; $this->_level = $section->getLevel() + 1; if (0 === $this->_position) { $this->_position = 1; } } $this->_section = $section; return $this; }
public function deleteSection(Section $section) { $page_repo = $this->getEntityManager()->getRepository('BackBee\\CoreDomain\\NestedNode\\Page'); $pages = $page_repo->createQueryBuilder('p')->andParentIs($section->getPage())->andIsNotSection()->getQuery()->execute(); foreach ($pages as $page) { $page_repo->deletePage($page); } $sections = $page_repo->createQueryBuilder('p')->andParentIs($section->getPage())->andIsSection()->getQuery()->execute(); foreach ($sections as $section) { $this->deleteSection($section->getSection()); } $this->getEntityManager()->remove($section); }