Beispiel #1
0
 /**
  * Parse a single page into a route configuration
  *
  * @param  Page $page
  * @return array
  * @throws Exception\RuntimeException
  */
 public function parsePage(Page $page)
 {
     $module = $this->getModuleRoute($page->getModule());
     $type = 'literal';
     if (isset($module['type'])) {
         $type = $module['type'];
     }
     $route = $page->getRoute(true);
     $route = '/' . trim($route, '/');
     if (isset($module['options']['route'])) {
         $route .= $module['options']['route'];
     }
     if (!isset($module['options']['defaults'])) {
         throw new Exception\RouteConfigurationException(sprintf('Module %s should provide defaults in route to dispatch a controller', $page->getModule()));
     }
     $defaults = array('page-id' => $page->getId()) + $module['options']['defaults'];
     $route = array('type' => $type, 'options' => array('route' => $route, 'defaults' => $defaults), 'may_terminate' => true);
     if (isset($module['options']['constraints'])) {
         $route['options']['constraints'] = $module['options']['constraints'];
     }
     if (isset($module['child_routes'])) {
         $route['child_routes'] = $module['child_routes'];
     }
     return $route;
 }
Beispiel #2
0
 /**
  * Parse a single page into a navigation configuration
  *
  * @param  Page $page
  * @return array
  * @throws Exception\RuntimeException
  */
 public function parsePage(PageInterface $page)
 {
     $meta = $page->getMetaData();
     $navPage = Page::factory(array('type' => 'mvc', 'route' => (string) $page->getId(), 'label' => $meta->getNavigationTitle(), 'visible' => $page->isVisible()));
     $event = new Event();
     $event->setName(__FUNCTION__ . '.' . $page->getModule());
     $event->setTarget($this);
     $event->setParams(array('page' => $page, 'navigation' => $navPage));
     $this->events->trigger($event);
     return $navPage;
 }