php - Phalcon PHP:调度程序的“转发”功能不起作用
问题描述
在reentryAction
我CustomerclientController
想转发到indexAction
帖子参数的有效性检查成功的情况下。
不幸的是,前锋不起作用。在调试时,我确定将再次调用reentryAction 方法,而不是indexAction。
我在我services.php
的下面注册了一个 Dispatcher:
$di->setShared('dispatcher', function() use ($eventsManager) {
$dispatcher = new MvcDispatcher();
// Bind the eventsManager to the view component
$dispatcher->setEventsManager($eventsManager);
return $dispatcher;
});
客户客户端控制器:
class CustomerclientController extends Controller {
public function reentryAction($hash) {
// ... a lot of code
if ($this->request->isPost()) {
// ... a lot of code
if ($valid) {
$this->dispatcher->forward([
"customerclient",
"index"
]);
return;
}
}
}
public function indexAction() {
//Does something wise
}
}
我没有定义特殊的路线,也没有使用route.php
文件。
我做错了什么或者我忘记了什么?
在此先感谢您的帮助!
解决方案
首先,尝试返回dispatcher->forward()。其次,也许将键写在数组中。
if ($valid)
return $this->dispatcher->forward([
"controller" => "customerclient",
"action" => "index"
]);
希望有帮助!
推荐阅读
- sql - 条件选择和更新行与前/后行
- firebase - Firebase crashlytics 映射文件未在 Ubuntu AWS 容器上上传
- java - 使用 Thymeleaf 和 Angular 的 Spring MVC 静态资源版本控制
- angular - 选择框不显示角度 10 中的选定值,但使用相同代码显示角度 8
- r - 如何根据几个条件计算 R 中数据的平均值
- r - 如何grepl搜索字符串中的最大和最小时间?
- html - 如何在 HTML 中使用引导列?
- javascript - 按钮充当复选框并更改样式?
- python - BI LSTM 在 python 中具有注意力层,用于文本分类
- angular - 角路由器链接到路径