Created
February 14, 2012 07:12
-
-
Save harikt/1824416 to your computer and use it in GitHub Desktop.
Routes for ZF , shown in example
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 | |
{ | |
/** | |
* | |
* Routes | |
*/ | |
protected function _initRoutes() | |
{ | |
$frontController = Zend_Controller_Front::getInstance(); | |
$router = $frontController->getRouter(); | |
$router->removeDefaultRoutes(); | |
$router->setGlobalParam('lang', 'en'); | |
$route = new Zend_Controller_Router_Route( | |
':lang/:module/:controller/:action/*', | |
array( | |
'lang' => 'en', | |
'module' => 'default', | |
'controller' => 'index', | |
'action' => 'index' | |
) | |
); | |
$router->addRoute('default', $route); | |
$router->addRoute( | |
'product', | |
new Zend_Controller_Router_Route(':lang/:country/:province/:city/:product', array( | |
'lang' => 'en', | |
'controller' => 'country', | |
'action' => 'product' | |
)) | |
); | |
$router->addRoute( | |
'city', | |
new Zend_Controller_Router_Route(':lang/:country/:province/:city', array( | |
'lang' => 'en', | |
'controller' => 'country', | |
'action' => 'city' | |
)) | |
); | |
$router->addRoute( | |
'province', | |
new Zend_Controller_Router_Route(':lang/:country/:province', array( | |
'lang' => 'en', | |
'controller' => 'country', | |
'action' => 'province' | |
)) | |
); | |
$router->addRoute( | |
'country', | |
new Zend_Controller_Router_Route(':lang/:country', array( | |
'lang' => 'en', | |
'controller' => 'country', | |
'action' => 'index' | |
)) | |
); | |
$router->addRoute( | |
'contact', | |
new Zend_Controller_Router_Route(':lang/contact', array( | |
'lang' => 'en', | |
'controller' => 'contact', | |
'action' => 'index' | |
)) | |
); | |
} | |
} | |
/** | |
* Current Routes in the above | |
* | |
* http://zfroute.local/ | |
* http://zfroute.local/en | |
* http://zfroute.local/en/contact | |
* http://zfroute.local/en/country | |
* http://zfroute.local/en/country/province | |
* http://zfroute.local/en/country/province/city | |
* http://zfroute.local/en/country/province/city/product | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment