Within the reentryAction
in my CustomerclientController
I want to forward into the indexAction
in case of successful validity check of the post parameters.
Unfortunately, the forward doesn't work. While debugging, I determined that the reentryAction method will be called again, instead of indexAction.
I registered a Dispatcher in my services.php
as follows:
$di->setShared('dispatcher', function() use ($eventsManager) {
$dispatcher = new MvcDispatcher();
// Bind the eventsManager to the view component
$dispatcher->setEventsManager($eventsManager);
return $dispatcher;
});
The CustomerclientController:
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
}
}
I defined no special routes and do not use a route.php
file.
What am I doing wrong or what did I forget?
Thanks in advance for your help!
Are you sure you need use MvcDispatcher? I checked my project and I am using Dispatcher
$di->set('dispatcher', function() use ($di) {
$dispatcher = new Dispatcher;
$dispatcher->setEventsManager($eventsManager);
return $dispatcher;
});
I hope it works!