Пример #1
0
 public function getRouteCollectionForRequest(Request $request)
 {
     $collection = new RouteCollection();
     $path = $request->getPathInfo();
     if ('/-1' === $path) {
         return $collection;
     }
     $slugs = explode('/', trim($path, '/'));
     $slug = array_pop($slugs);
     $page = $this->repos->findOneBy(array('slug' => $slug));
     if (!$page) {
         return $collection;
     }
     $_page = $page->getParent();
     while (count($slugs)) {
         $_slug = array_pop($slugs);
         if (!$_page || $_slug !== $_page->getSlug()) {
             return $collection;
         }
         $_page = $_page->getParent();
     }
     if ($_page) {
         return $collection;
     }
     $template = $page->getPageTemplate();
     if (!$template) {
         $template = $this->template;
     }
     $defaults = array('_controller' => $this->controller, '_page_template' => $template, '_page_object' => $page);
     $requirements = array();
     $route = new Route($path, $defaults, $requirements);
     $name = 'sf_page_' . $page->getSlug();
     $collection->add($name, $route);
     return $collection;
 }
Пример #2
0
 /**
  * @return ItemInterface
  */
 public function createExtraMenu()
 {
     $page = $this->repository->findOneBy(['title' => Page::EXTRA_MENU_TITLE]);
     return $this->createMenu($page);
 }
Пример #3
0
 public function findOneBySlugAndAdministration(Administration $administration, $slug)
 {
     return parent::findOneBy(array('administration' => $administration, 'slug' => $slug));
 }