Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Unable to render template RuntimeException for AbstractRestfulController #3

Open
jerv13 opened this issue May 26, 2015 · 5 comments
Open

Comments

@jerv13
Copy link

jerv13 commented May 26, 2015

I get an unable to render template error when i do not over-ride the AbstractRestfulController method.

By default, the response code is set and an array is returned which appears to be picked up and rendered using the default render strategy.

Would it be a good idea to set the response content and return the response or is there something I am missing in the configuration.

I would just like some feedback on this before I make a pull request.

Thanks,

James

@rodmcnew
Copy link
Contributor

I've ran into this issue many times as well and haven't found a good solution.

One way to recreate this is to extend the AbstractRestfulController and implement the get() action but not the getList() action. Then when you go to the getList route, you get a "template not found" error instead of a "Method Not Allowed" response like any other framework gives.

It doesn't make sense for me to have to create a "module-name/controller-name/get-list.phtml" template for every rest controller I create when I don't even want to implement "getList" functionality.

@scroach
Copy link

scroach commented Dec 9, 2015

I've stumbled across the same problem as I am currently trying to implement a REST API with ZF2.
I registered the ViewJsonStrategy in my module and expected the AbstractRestfulController to return JSON-Based error-responses for unimplemented methods.

Afte some research I found out that the JsonStrategy has been changed long ago in 2.0.4 to only return JSON if a JsonModel has been explicitely returned.
http://framework.zend.com/blog/zend-framework-2-0-4-released.html

So in my understanding the AbstractRestfulController shouldn't return plain arrays in the pre-implemented methods but JsonModel containing the array. This would produce something like this:

{"content":"Method Not Allowed"}

Am I right?!

@karborator
Copy link

karborator commented Jun 21, 2016

@chaos0815
Copy link

Is there a reason why AbstractRestfulController returns an array in the pre-implemented methods instead of an JsonModel object?

@michalbundyra
Copy link
Member

This repository has been closed and moved to laminas/laminas-mvc; a new issue has been opened at laminas/laminas-mvc#34.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants