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); } }
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); }