如何为cakephp 3 plguin制作语言路线

时间:2017-02-24 17:58:13

标签: php cakephp-3.0

Router::scope('/:language/employer/', ['plugin' => 'EmployerPanel'], function ($routes) {  
    $routes->prefix('employer',function ($routes) {
        $routes->connect(':language/:controller',['plugin'=>'EmployerPanel']);
    });
     $routes->fallbacks('InflectedRoute');
});

这必须与 EmployerPanel 插件中的插件一起使用,页面控制器和操作在家中使用语言en。

http://localhost/mmjob/en/empoyer/pages/home

但它在调试请求中

language   => en
controller => Employer
action     => pages
pass(array)
plugin(null)
_matchedRoute/:language/:controller/:action/*
_ext(null)

我该如何处理_matchedRoute = /:language/:plugin/:controller:/:action

1 个答案:

答案 0 :(得分:0)

试试这个:

Router::plugin(
    'EmployerPanel',
    ['path' => '/employer-panel'],
    function ($routes) {
        $routes->connect('/:language/employer/', ['plugin' => 'EmployerPanel', 'controller' => 'Pages', 'action' => 'home']);
        $routes->fallbacks('InflectedRoute');
    }
);

Go to http://localhost/mmjob/employer-panel/en/employer