开发者

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.

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

 // 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 ou开发者_高级运维tlined above in bootstrap.php

How can I do this? Thanks


Using Request::factory with the uri:

$request->response = Request::factory('error/404')->execute();

Or with the route:

$request->response = Request::factory(Route::get('error_404')->uri())->execute();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜