Пример #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;
 }