On Wed, Feb 27, 2013 at 11:09 PM, Greg <[email protected]> wrote: > Looking at the Skeletal app, I made the following changes > > 1. Moved the Controller director to src/Application/Admin > 2. Moved the view index directory to view/application/admin. > 3. Added namespace Application\Admin\Controller to the 'home' route > 4. Changed the default route namespace to Application\Admin\Controller > 5. Changed the invokables configuation to Application\Admin\Controller\Index > 6. Created the controller > src/Application/Admin/Controller/IndexController.php > > I then got the following error: > > Unable to render template "application/controller/index/index"; > > I'm thinking this should still of worked and should look for > application/admin/index/index. > > Looking at the comment in > InjectTemplateListener::deriveControllerSubNamespace > > // Remove the first two elements representing the module and controller > directory. > > Makes me wonder if this assumption is too rigid? > > Since it seems like all defined namespaces in the route config must end > with \Controller, I'm wondering if deriveControllerSubNamespace should just > remove the term Controller from the end of $namespace and then just remove > the first segment of the namespace (i.e the module name)?
That's not a safe assumption. If I don't have many controllers, or many classes for that matter, I will often flatten my directory structure. As such, I might not have a "\Controller" subnamespace. And we make no requirements about appending the word "Controller" to the class, either. I've also seen people group a controller and its dependencies in a subnamespace without using a subnamespaced-module. The point is: we don't make many assumptions about how the code inside a module is structured -- and imposing something like what you're wanting would break code for a lot of folks. I *do* think this should likely be configurable per-module, as I've seen a number of cases like yours where the view template name injection simply doesn't work; I'm just not sure yet how to accomplish it. In the meantime, you could create a controller or module-specific listener for injecting the view template name. -- Matthew Weier O'Phinney Project Lead | [email protected] Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc -- List: [email protected] Info: http://framework.zend.com/archives Unsubscribe: [email protected]
