我想知道如果有人写一个不存在的链接会在cakephp 3中返回错误。
示例:
我首先在控制器calle中有一个名为test的动作。
在我的路由文件中,我已在scope
内以这种方式声明了语言:
$lang = 'it|en';
$routes->connect('/', ['language' => 'it', 'controller' => 'Pages', 'action' => 'index', 'index'],
['language' => $lang]);
$routes->connect(
'/:language/:controller',
['action' => 'index'],
['language' => $lang]
);
$routes->connect(
'/:language/:controller/:action',
['language' => $lang]
);
所以我希望通过这个路由系统,如果有人在网址内写道:
`http://www.myownsite.it/languagenotexist/first/test` returns error, but take `languagenotexist` as a language but lang are only: 'it|en'.
如果参数语言不是我在路径文件中声明的那样,我怎么能返回错误?
这需要工作:
http://www.myownsite.it/it/first/test
或者
http://www.myownsite.it/en/first/test
这需要像404一样返回错误:
http://www.myownsite.it/languagenotexist/first/test
或者
http://www.myownsite.it/es/first/test
因为参数语言不是或不是
路由表:
pages:index | / | {"language":"it","controller":"Pages","action":"index","0":"index","plugin":null} |
| _controller:index | /:language/:controller | {"action":"index","plugin":null} |
| _controller:_action | /:language/:controller/:action | {"language":"it|en","action":"index","plugin":null}