=====================================
return [
'router.routes' => [
'home' => [
'route' => '/',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'index',
],
],
'members' => [
'route' => 'members',
'defaults' => [
'controller' => AdminIndexController::class,
'action' => 'index',
],
],
],
];
Implicit options using (/<...>)
return [
'router.routes' => [
'event_action' => [
'route' => '/blogs/browse(/<sort>)',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'browse',
'sort' => 'recents'
],
],
],
];
Add condition to pattern wheres
return [
'router.routes' => [
'blog_action' => [
'route' => '/blog/<id>/<action>',
'wheres'=>[
'id'=>'\d+',
'action'=>(edit|delete|view|upgrade|settings)
],
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'index',
],
],
],
];
return [
'router.filters' => [
'@profile' => [null, ProfileNameFilter::class],
],
];
Apply filter to route
'filter' => '@profile',
return[
'router.routes' => [
'profile/members' => [
'route' => '<name>/{members}',
'filter' => '@profile',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'index',
],
],
],
];
You can add single one or multiple filter using [filter1, filter2,...], All filters will be traversed, The result will be true if the route passed all filter rules.
Translated phrase must be apply before RoutingManager constructing.
- Edit phrases in "$root/config/local.config.php"
- Translated phrases must not contain blank or special characters.
- Be careful that translated phrases does not duplicated another phrase in the same context.
return [
'router.phrases' => [
'{admincp}' => 'admincp',
'{blog}'=>'bài-viết',
'{members}=>'thành-viên',
],
];
service('routing')->getUrl('profile/members', ['name'=>'codelego']);
// origin "codelego/members"
// translated "codelego/thành-viên" if {member} is configured to "thành-viên".
Example:
posts/en/policy
posts/vi/policy
With "en" or "vi" will be added by the current member locale, But you don't want to put $locale to every getUrl() invoked. The simplest way is using EnvironmentParams.