/** * @param EntityManager $em * @param Page $page */ protected function removePageSlugs(EntityManager $em, Page $page) { foreach ($page->getSlugs() as $slug) { $page->removeSlug($slug); $em->remove($slug); } foreach ($page->getChildPages() as $childPage) { $this->removePageSlugs($em, $childPage); } }
public function testSlugAccessors() { $emptySlug = new Slug(); $emptySlug->setUrl('/'); $page = new Page(); $this->assertEquals([$emptySlug], $page->getSlugs()->toArray()); $firstSlug = new Slug(); $secondSlug = new Slug(); $page->addSlug($firstSlug)->addSlug($secondSlug); $this->assertEquals([$emptySlug, $firstSlug, $secondSlug], array_values($page->getSlugs()->toArray())); $page->removeSlug($firstSlug)->removeSlug($firstSlug); $this->assertEquals([$emptySlug, $secondSlug], array_values($page->getSlugs()->toArray())); }