发送404到定制路线的Kohana 3
-
20-09-2019 - |
题
我已经看了如何 shadowhand (目前Kohana的背后主要的家伙)成立了bootstrap.php
文件来处理异常上 GitHub的。
我想,“这是酷”,所以并入类似的东西。
然而,代替煮好的图,我想发送到不同的路径的请求(或至少它指向一个控制器/动作对)。
因此,这部分在GitHub
// Create a 404 response
$request->status = 404;
$request->response = View::factory('template')
->set('title', '404')
->set('content', View::factory('errors/404'));
会是这样的(当然伪代码)
// Create a 404 response
$request->status = 404;
$request->response = Route::get('404_error'); // which will map to a route outlined above in bootstrap.php
我怎样才能做到这一点?感谢
解决方案
使用支持::工厂与URI:
$request->response = Request::factory('error/404')->execute();
或者与该路线:
$request->response = Request::factory(Route::get('error_404')->uri())->execute();
不隶属于 StackOverflow