Controller and layout name in views directory

Is it a bug or a feature? Or I've just missed something in documentation.

For example I have an IndexController::indexAction().

If I define routes in a class extended from \Phalcon\Mvc\Router\Group then view rendering from views/index/index.phtml. Routes are mounting using Phalcon\Mvc\Router\Annotations::mount() function.

But if I use \Phalcon\Mvc\Router\Annotations::addModuleResource() to add module-related routings then views are looking in different folder. Instead of views/index/index.phtml they should be placed in views/Index/index.phtml. Controller name is capitalized.

Layout acts the same way. It should be in views/layouts/index.phtml or in views/layouts/Index.phtml, respectively.

Unfortunately, I want to use both way to define routes, as annotation and mount them to router. Is it possible?



579

Some code expamles.

My controller class: ```php namespace Frontend\Controller;

/* * @RouterPrefix("/") */ class IndexController extends \Phalcon\Mvc\Controller { /* * @Get("home", name="home") */ public function indexAction() { } } ```

Routes in class ```php class Routes extends \Phalcon\Mvc\Router\Group { public function initialize() { $this->setPaths(array( 'module' => 'frontend', 'namespace' => 'Frontend\Controller', ));

    $this->setPrefix('/');

    // Route to homepage
    $this->add('home', [
        'controller' => 'index',
        'action' => 'index',
    ]);
}

} ```

Application bootstrap:

$router = new \Phalcon\Mvc\Router\Annotations(false);

$router->addModuleResource('frontend', 'Frontend\Index'); // *1*
$router->mount(new Routes()); // *2*

For line 1 beforeExecuteRoute $dispatcher->getControllerName() === 'Index'

For line 2 $dispatcher->getControllerName() === 'index'



579

Have fixed issue with the following code in dispatcher: ```php $di->set('dispatcher', function () { //Create an EventsManager $eventsManager = new EventsManager();

        //Camelize controller
        $eventsManager->attach(
            'dispatch:beforeDispatchLoop',
            function ($event, $dispatcher) {
                $controller = Text::camelize($dispatcher->getControllerName());
                $dispatcher->setControllerName($controller);
            }
        );

        $dispatcher = new Dispatcher();
        $dispatcher->setEventsManager($eventsManager);
        $dispatcher->setDefaultNamespace('Frontend\Controller');

        return $dispatcher;
    });

``` So, I simply capitalize every controller name.