public function createFromPageAction(Request $request, $rootId, $pageId) { $rootNode = $this->admin->getObject($rootId); if (!$rootNode) { throw new NotFoundHttpException(sprintf('unable to find the Menu with id : %s', $rootId)); } $page = $this->get('networking_init_cms.page_manager')->find($pageId); if (!$page) { throw new NotFoundHttpException(sprintf('unable to find the Page with id : %s', $pageId)); } $menuItem = new MenuItem(); $menuItem->setPage($page); $menuItem->setRoot($rootNode); $menuItem->setParent($rootNode); $menuItem->setName($page->getTitle()); $em = $this->getDoctrine()->getManager(); $em->persist($menuItem); $em->flush(); $this->admin->createObjectSecurity($menuItem); return $this->redirect($this->admin->generateUrl('list', array('page_id' => $page->getId(), 'menu_id' => $menuItem->getId())) . '#end'); }