[英]Send 404s to custom route in Kohana 3
I've looked at how shadowhand (the main guy behind Kohana currently) set up his bootstrap.php
file to handle exceptions on GitHub . 我看过shadowhand (当前Kohana背后的主要人物)如何设置他的
bootstrap.php
文件以处理GitHub上的异常。
I thought, "that's cool", so I incorporated something similar. 我想,“这很酷”,所以我加入了类似的东西。
However, instead of serving up a view, I'd like to send the request to a different route (or at least point it to a controller/action pair). 但是,我不想提供视图,而是将请求发送到不同的路径(或者至少将其指向控制器/操作对)。
So this part on GitHub 所以这部分在GitHub上
// Create a 404 response
$request->status = 404;
$request->response = View::factory('template')
->set('title', '404')
->set('content', View::factory('errors/404'));
Would be something like (pseudo code of course) 会是这样的(当然是伪代码)
// Create a 404 response
$request->status = 404;
$request->response = Route::get('404_error'); // which will map to a route outlined above in bootstrap.php
How can I do this? 我怎样才能做到这一点? Thanks
谢谢
Using Request::factory with the uri: 使用带有uri的Request :: factory:
$request->response = Request::factory('error/404')->execute();
Or with the route: 或者与路线:
$request->response = Request::factory(Route::get('error_404')->uri())->execute();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.