Issues

ZF2-279: RestfulController does not work with automatic template injection

Issue Type: Bug Created: 2012-04-25T16:45:11.000+0000 Last Updated: 2012-06-13T11:19:20.000+0000 Status: Resolved Fix version(s): Reporter: Chionsas (chionsas) Assignee: Evan Coury (evan.pro) Tags: - Zend\Mvc

Related issues: Attachments: - RestfulController.patch

Description

Execute() method in https://github.com/zendframework/zf2/… checks for 'action' parameter in RouteMatch and if it's not present, goes on to automatically determine the method [of the Controller] to be called based on the HTTP verb (get/post/put/delete) of the user request.

The problem is, after determining the correct action (method to be called), that action name is not stored anywhere. So the injectTemplate() method in https://github.com/zendframework/zf2/… goes on to use only the Controller's name for setting the template name (just 'index' instead of 'index/get' or 'index/create' or 'index/update' and so on). This is not the desired behavior.

RestfulController should set a RouteMatch action parameter based on the action taken (Controller method called), so that the template injection mechanism would try to use the template name expected. Alternatively, a differently named parameter could be set (say, '_action') to differentiate for when the action is set by the router and when it's set by the controller (or anywhere outside the router), but this would require changes to \Mvc\View\TemplateInjection.php and I currently consider this approach to be too cumbersome and unnecessary.

Comments

Posted by Chionsas (chionsas) on 2012-04-25T17:06:40.000+0000

patch added :)

Posted by Evan Coury (evan.pro) on 2012-06-13T11:18:03.000+0000

Your patch file wasn't generated right (it's blank), but I found the commit on your Github, cherry-picked it, and fixed the whitespace issues (tab vs 4 spaces). PR is here: https://github.com/zendframework/zf2/pull/1491

Posted by Evan Coury (evan.pro) on 2012-06-13T11:19:20.000+0000

Fixed with PR 1491.

https://github.com/zendframework/zf2/pull/1491

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