/** * @param Page $page * @param $path_str * @param RouteCollection $routes * @throws \Exception * @throws \PropelException */ private function addPageRoute(Page $page, $path_str, RouteCollection $routes) { $route = new Route($path_str . '/{page_id}', array('_controller' => $this->getPageControllerName(), 'page_id' => (string) $page->getId()), array('page_id' => (string) $page->getId())); $route_name = 'etfostra_content_' . $page->getId(); $routes->add($route_name, $route); $page->setRouteName($route_name)->save(); }
/** * Ajax add Page * * @param Request $request * @return JsonResponse * @throws \Exception * @throws \PropelException */ public function ajaxAddAction(Request $request) { if (false === $this->admin->isGranted('CREATE')) { throw new AccessDeniedException(); } $parent = PageQuery::create()->findOneById($request->query->get('parentId')); if (!$parent) { throw new \Exception(); } $page = new Page(); $page->setLocale($request->getLocale()); $page->setTitle($request->query->get('name')); $page->insertAsLastChildOf($parent); $page->save(); $this->clearRouteCache(); return new JsonResponse(array('id' => $page->getId())); }