我已经为我的 ACL 设置了一个 preDispatch 插件。我将 Controller 用作资源,将操作用作特权。当我尝试转到一个不存在的页面时,我进入了拒绝访问页面而不是 404,我认为是因为资源和特权被查询并且由于未找到它们,所以它进入了拒绝访问页面......
我该如何解决这个问题?也许我实现插件的方法是错误的?我可以以某种方式检查我的 acl 插件运行的现有资源 b4 吗?\
更新
插件代码@ pastebin
最佳答案
我遇到了同样的问题并将其添加到 preDispatch
函数中(尽管使用模块,但有趣的是 $acl->has()
函数):
if (!$acl->has($request->module . '_' . $request->controller)) {
// action/resource does not exist in ACL
$request->setModuleName('default');
$request->setControllerName('error');
$request->setActionName('notfound');
} else {
// resource does exist, check ACL
if (!$acl->isAllowed($role, $module . '_' . $controller, $action)) {
$request->setControllerName('user');
$request->setActionName('login');
}
}
关于php - Zend 框架 : preDispatch ACL plugin causes requests to non existent page to Access Denied instead of 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3421761/