I want to route requests by processing http post vars, e.g. by putting and the like for "module", "controller", "action", etc., in a form, setting the action="..." target of the form to the application's default route and from there route to the module/controller/action route. The routes to module/controller/action shall not be accessible by the URL /module/controller/action, so the problem is, if the routes are configured in module.config.php, then they become accessible through the URL also? I may be missing a point there, it might be straightforward and simple, if only I knew the proper configuration for the routing in module.config.php, or is it necessary to set up an own custom routing service?
The redirect to route would reveal the route URL in the browser's address bar, and that is what I want to avoid, and don't know how.
if ($this->request->isPost()) {
$post = $this->request->getPost();
if (isset($post->module) && isset($post->controller) && isset($post->action)) {
return $this->redirect()->toRoute($post->module, array(
'controller' => $post->controller,
'action' => $post->action
));
}
}
EDIT: Found half a solution: Use \Mvc\Controller\Plugin\Forward, like this:
in the application's default controller/action, calling a controller by its name as defined in the invokables section in the module.config.php, e.g. for a controller named 'register':
if ($this->request->isPost()) {
$post = $this->request->getPost();
if (isset($post->module) && isset($post->controller) && isset($post->action)) {
return $this->forward()->dispatch('register', array('action' => $post->action));
}
}
Now I need to get the controller invokable name from the module/controller name as from the post vars. How?