Пример #1
0
 /**
  * @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();
 }
 /**
  * Is current route match any child of page
  *
  * @param Page $page
  * @return bool
  */
 protected function isPageSubActive(Page $page)
 {
     $current_route_name = $this->get('request')->get('_route');
     if ($page->getRouteName() == $current_route_name) {
         return false;
     }
     $possible_child = PageQuery::create()->findOneByRouteName($current_route_name);
     if (!$possible_child) {
         return false;
     }
     if ($page->isAncestorOf($possible_child)) {
         return true;
     } else {
         return false;
     }
 }
 /**
  * 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()));
 }