繁体   English   中英

发送404s到Kohana 3的自定义路线

[英]Send 404s to custom route in Kohana 3

我看过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 :: factory:

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

或者与路线:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM