0

reentryActionCustomerclientController想转发到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文件。

我做错了什么或者我忘记了什么?

在此先感谢您的帮助!

4

2 回答 2

0

首先,尝试返回dispatcher->forward()。其次,也许将键写在数组中。

if ($valid) 
  return $this->dispatcher->forward([
    "controller" => "customerclient",
    "action" => "index"
  ]);

希望有帮助!

于 2018-08-10T14:59:01.470 回答
0

你确定你需要使用 MvcDispatcher 吗?我检查了我的项目,我正在使用 Dispatcher

$di->set('dispatcher', function() use ($di) {
    $dispatcher = new Dispatcher;
    $dispatcher->setEventsManager($eventsManager);
    return $dispatcher;
}); 

我希望它有效!

于 2018-08-24T17:36:20.000 回答