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

InjectTemplateListener return proper api template #164

Closed
wants to merge 8 commits into from

Conversation

karborator
Copy link

InjectTemplateListener return proper api template if prefer_route_match_controller is set to true from route config.This way we can set controller_map and as a result ,apigility will return proper api template ,instead to look for template zf/rest/action.phtml ( get-list.phtml )

                'defaults' => array(
                    'controller' => 'Ecommerce\\V1\\Rest\\Sales\\Controller',
                    'prefer_route_match_controller' => true
                ),

nikolay added 2 commits June 19, 2016 15:59
…th true in config route

This way we can set controller_map and as a result ,apigility will return proper api template
@weierophinney
Copy link
Member

Please provide a test; i don't fully interstage what the patch is trying to accomplish.

@karborator
Copy link
Author

karborator commented Jun 21, 2016

This patch is to solve issues like : #3

@rodmcnew
Copy link
Contributor

Just to clarify, #3 is about how the the AbstractRestfulController looks for templates and returns "500 internal server error" for undefined methods rather than returning "405 method not allowed".

Does this fix that?

@karborator
Copy link
Author

karborator commented Jun 21, 2016

It will fix the problem with returning of proper template ... . when using rest API controller
You can simple make a test .Clone my fork https://github.com/karborator/zend-mvc ,
create rest api , create controller_map of controller and template path and set 'prefer_route_match_controller' => true at the controller route .
Configure apigility to return proper content negotiation also ...

This way the inject listener will detect what template you want for your API

From comments - #3

" 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. "

@weierophinney
Copy link
Member

Closing in favor of #163, which also incorporates the same commits.

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

Successfully merging this pull request may close these issues.

3 participants