Пример #1
0
 /**
  * {@inheritdoc}
  *
  * In addition, load routes from file if a file was specified
  * 
  * @return Router
  */
 public function init()
 {
     $routes = array();
     foreach ($this->getOptions() as $key => $value) {
         if (strtolower($key) == 'file') {
             $routes = (include $value);
             break;
         }
     }
     $this->setOptions(array('routes' => $routes));
     return parent::init();
 }
Пример #2
0
 /**
  * @return Zend_Controller_Router_Rewrite
  */
 public function init()
 {
     $router = parent::init();
     $front = $this->getBootstrap()->getResource('Frontcontroller');
     if ($front->getParam('api')) {
         // The API route is the only valid route for an API request.
         $router->addRoute('api', new Omeka_Controller_Router_Api());
     } else {
         $router->addConfig(new Zend_Config_Ini(CONFIG_DIR . '/routes.ini', 'routes'));
         fire_plugin_hook('define_routes', array('router' => $router));
         $this->_addHomepageRoute($router);
     }
     return $router;
 }
Пример #3
0
 public function testOptionsPassedToResourceAreUsedToCreateRoutes()
 {
     $options = array('routes' => array('archive' => array('route' => 'archive/:year/*', 'defaults' => array('controller' => 'archive', 'action' => 'show', 'year' => 2000), 'reqs' => array('year' => '\\d+'))));
     $resource = new Zend_Application_Resource_Router($options);
     $resource->setBootstrap($this->bootstrap);
     $resource->init();
     $router = $resource->getRouter();
     $this->assertTrue($router->hasRoute('archive'));
     $route = $router->getRoute('archive');
     $this->assertTrue($route instanceof Zend_Controller_Router_Route);
     $this->assertEquals($options['routes']['archive']['defaults'], $route->getDefaults());
 }
Пример #4
0
 public function init()
 {
     parent::init();
 }