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)?

Making those changes to deriveControllerSubNamespace seems to work

protected function deriveControllerSubNamespace($namespace)
{
    if (!strstr($namespace, '\\')) {
        return '';
    }

    if ('Controller' == substr($namespace, -10)) {
        $namespace = substr($namespace, 0, -11);
    }

    $nsArray = explode('\\', $namespace);

    // Remove the first two elements representing the module and controller
directory.
    $subNsArray = array_slice($nsArray, 1);
    if (empty($subNsArray)) {
        return '';
    }
    return implode('/', $subNsArray);
}


Some extra tweaking would probably be needed if the module has no namespace
(i.e. line 99 of InjectTemplateListener.php).

Or have I misunderstood something in the configuration?


-- 
Greg

Reply via email to