Created
June 18, 2014 08:31
-
-
Save ezimuel/92d9f6b8ed62f9fd71c7 to your computer and use it in GitHub Desktop.
Optional language parameter in a ZF2 route
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 | |
// route configuration, for instance in a module.config.php | |
// ... | |
'home' => array( | |
'type' => 'segment', | |
'options' => array( | |
'route' => '/[:lang/]', | |
'defaults' => array( | |
'__NAMESPACE__' => 'Application\Controller', | |
'controller' => 'Index', | |
'action' => 'index', | |
'lang' => 'en', | |
), | |
'constraints' => array( | |
'lang' => 'en|fr' | |
), | |
), | |
'may_terminate' => true, | |
'child_routes' => array( | |
'page-one' => array( | |
'type' => 'segment', | |
'options' => array( | |
'route' => 'page-one', | |
'defaults' => array( | |
'controller' => 'Application\Controller\Index', | |
'action' => 'page-one', | |
), | |
), | |
), | |
'page-two' => array( | |
'type' => 'segment', | |
'options' => array( | |
'route' => 'page-two', | |
'defaults' => array( | |
'controller' => 'Application\Controller\Index', | |
'action' => 'page-two', | |
), | |
), | |
), | |
), | |
), | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment