Issues

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

Issue Type: Bug Created: 2012-06-07T06:24:18.000+0000 Last Updated: 2012-10-08T20:15:13.000+0000 Status: Closed Fix version(s): Reporter: Yonni Mendes (yonman) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend\Mvc

  • Mvc
  • Plugin

Related issues: Attachments:

Description

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

<pre class="highlight">

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.

<pre class="literal">
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.

<pre class="highlight">

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

Comments

Posted by Ralph Schindler (ralph) on 2012-10-08T20:15:13.000+0000

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

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts