Reputation: 14532
I have two actions in a controller: actionA()
and actionB()
. Dependent on a condition the actionA()
should return a ViewModel
object or be forwarded to actionB()
(and return its result):
class MyController extends AbstractActionController {
public function aAction() {
...
$data = ...
...
if (...) {
$result = new ViewModel(array(
'data' => $data,
));
} else {
$result = $this->forward()->dispatch('MyModule\Controller\My', array(
'action' => 'b',
));
}
return $result;
}
I tried it with
$result = $this->forward()->dispatch('MyModule\Controller\My', array(
'action' => 'b',
'data' => $data,
));
But I have no idea, how to fetch this data now.
I'm sure, it's possible. How can I do it?
Upvotes: 1
Views: 161
Reputation: 14532
public function bAction() {
...
// so:
$params = $this->params()->fromRoute();
// or so:
$params = $this->getEvent()->getRouteMatch()->getParams();
...
}
Upvotes: 0