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

ZF3 assumes that the folder with the module's controllers has to be named Controller #7744

Open
ddodz opened this issue Nov 14, 2016 · 6 comments

Comments

@ddodz
Copy link

ddodz commented Nov 14, 2016

After migrating to ZF3 from ZF2 found out an issue. It seems internally, ZF3 assumes that the folder with the module's controllers has to be named Controller (singular). If that's not the case, like I named Controllers (plural), it lets the namespace YourModule/Controllers/ControllersName/ to be transferred to the path your-module/controllers/controllers-name/ instead of your-module/controllers-name (then attaching the action). All this happens in the InjectTemplateListener's mapController() method. I guess it's a bug because things worked for ZF2 without a problem.

@ddodz
Copy link
Author

ddodz commented Nov 16, 2016

I also find a bit uncomfortable the following thing. In ZF2, there shouldn't have been an exact correspondence between the path to the controller and the resulting view script path. I mean the following: if a path to a specific controller is MyModule/Controllers/SomeFolder/SomeFolder2/DesiredController, the view script's path could have been like my-module/some-folder/desired, whereas now the view script path must resemble the controller path my-module/some-folder/some-folder2/desired. It's not a big issue, though, I find it a bit uncomfortable when you want to provide some structure in the controllers' folder (multiple nesting folders) and still keep the urls simple.

@jhonmike
Copy link

Something is wrong with your code for sure it is not the zend obligadno any kind of nameclatura pattern ...

My folder with the controllers is called Services and works perfect on zf3 heheh

@ddodz
Copy link
Author

ddodz commented Nov 17, 2016

I'm not sure it's my fault. :-) if you look at InjectTemplateListener you'll see what i mean. By the way, can you tell me the full path to your controller folders? and it is painful to hear that it works for you and not for me :-)))))

@Ocramius Ocramius changed the title ZF3 ZF3 assumes that the folder with the module's controllers has to be named Controller Jan 16, 2017
@Ocramius
Copy link
Member

@ddodz can this be moved to zendframework/zend-mvc? A test case with your current scenario would also be needed to verify if ZF2->3 caused a regression.

@oprokidnev
Copy link

oprokidnev commented Feb 10, 2017

@ddodz Both zf2 and zf3 does not support this transformation. But there is a simple way to perform this by yourself. You can attach an event listener, that will inject template following your name transformation rules before InjectTemplateListener will do the same. Docs telling us, that InjectTemplateListener is attached to SharedEventManager with Zend\Stdlib\DispatchableInterface context. Just add your template name resolver using higher (e.g. 91) priority.

@oprokidnev
Copy link

For me it will be even better to store controller views within controller folder. In my case one module can provide not only controller templates, but viewhelpers, form elements, navigation and other templatesю

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

4 participants