Created
December 1, 2010 14:50
-
-
Save nebiros/723579 to your computer and use it in GitHub Desktop.
Zend Framework bootstrap hacks and features
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { | |
/** | |
* | |
* @return void | |
*/ | |
protected function _initRouting() { | |
/* @var $fc Zend_Controller_Front */ | |
$fc = $this->getPluginResource( "frontcontroller" )->getFrontController(); | |
/* @var $router Zend_Controller_Router_Abstract */ | |
$router = $fc->getRouter(); | |
$router->addDefaultRoutes(); | |
$routes = $router->getRoutes(); | |
/* @var $locale Zend_Locale */ | |
$locale = $this->getPluginResource( "locale" )->getLocale(); | |
// append locale region to each default routes. | |
$hook = new Zend_Controller_Router_Route( | |
":country", | |
array( "country" => strtolower( $locale->getRegion() ) ), | |
array( "country" => "[a-z]{2}" ) | |
); | |
foreach ( $routes as $name => $route ) { | |
$chain = new Zend_Controller_Router_Route_Chain(); | |
$chain->chain( $hook )->chain( $route ); | |
$router->addRoute( $name, $chain ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment