Public paste
Undefined
By: Guest | Date: Mar 26 2010 10:01 | Format: None | Expires: never | Size: 1.4 KB | Hits: 893

  1. protected function _initFrontControllerConfiguration()
  2.     {
  3.  
  4.         $this->bootstrap('FrontController');
  5.  
  6.         $front = $this->getResource('FrontController');
  7.  
  8.         $front->registerPlugin(new Zend_Controller_Plugin_ErrorHandler(array(
  9.             'module'     => 'default',
  10.             'controller' => 'error',
  11.             'action'     => 'error'
  12.         )));
  13.  
  14.         $front->setDefaultModule('index');
  15.         $front->setDefaultControllerName('index');
  16.         $front->setDefaultAction('index');
  17.  
  18.         $front->setParam('prefixDefaultModule', true);
  19.        
  20.         // Inits instance of Zend_Controller_Framework
  21.         $ctrl = Zend_Controller_Front::getInstance();
  22.         // Gets default router
  23.         $router = $ctrl->getRouter();
  24.         // Gets all valid routes, auto-created by control panel
  25.         // This routes are not standart, not dispatched by default
  26.         // rule :module/:controller/:action/*
  27.         $validRoutes = new Zend_Config_Xml(APPLICATION_PATH . '/configs/routing/routes.xml', null);
  28.        
  29.         // Adds this routes to router  
  30.         foreach ($validRoutes as $validRoute) {
  31.             $routeName = $validRoute->defaults->module[0] . '_';       
  32.             $routeName .= str_replace('/', '', rtrim($validRoute->route, '/'));
  33.        
  34.             $router->addRoute( 
  35.                 $routeName,    
  36.                 new Zend_Controller_Router_Route(      
  37.                     $validRoute->route . '*',  
  38.                     $validRoute->defaults->toArray()   
  39.                 )      
  40.             ); 
  41.         }