Issues

ZF2-345: After using Forward plugin render fails on Resolver error

Description

Using beta4. After using the forward plugin in a controller action and then returning a different view model causes a resolver error:



class IndexController extends ActionController
{
 public function indexAction() {
  $viewModel = $this->forward()->dispatch('SomeOtherController', array(...));
  .
  .
  .
  return new ViewModel(array(...));
 }
}

The above snippet causes the InjectViewModel::injectViewModel triggered by the 'render' event to introduce a 2nd view model under the layout, which calls to a mangled view script made of the original action's name and the forwarded view script's directory name... which doesn't exist and so fails.

PHP Fatal error:  Uncaught exception 'Zend\View\Exception\RuntimeException' with message 'Zend\View\Renderer\PhpRenderer::render: Unable to render template "servers/web-api/index"; resolver could not resolve to a file

Note the path above - servers is the namespace, web-api is the name of the "other controller" and index is the action for the "current controller".

Work around - Return the forward's output view model. This seems to avoid the issue some-why.



class IndexController extends ActionController
{
 public function indexAction() {
  $viewModel = $this->forward()->dispatch('SomeOtherController', array(...));
  .
  .
  .
  return $viewModel;
 }
}

Comments

This issue has been closed on Jira and moved to GitHub for issue tracking. To continue following the resolution of this issues, please visit: https://github.com/zendframework/zf2/issues/2490