Skip to content

Instantly share code, notes, and snippets.

@nebiros
Created December 1, 2010 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nebiros/723579 to your computer and use it in GitHub Desktop.
Save nebiros/723579 to your computer and use it in GitHub Desktop.
Zend Framework bootstrap hacks and features
<?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