I have a single-module app with annotations-based routing (default routes enabled)...
//Router
$di->set('router', function() {
$router = new \Phalcon\Mvc\Router\Annotations(true);
$router->addResource('Controllers\Char', '/char');
return $router;
});
...with one controller like this...
namespace Controllers;
use Evehub\Models\Character;
use Phalcon\Mvc\Controller;
use Phalcon\Mvc\Dispatcher;
/**
* Class CharController
*
* @RoutePrefix('/char')
*/
class CharController extends Controller
{
private function setCommonData()
{
//Common view variables for every future action in this controller
$this->view->character = Character::findByName($this->dispatcher->getParam('charname'));
}
/**
* @Get('/{charname}')
*/
public function indexAction()
{
$this->setSharedData();
}
}
...and one without annotations (default routes). When request follows default routes (for example, '/index/test') - testAction in IndexController matched and rendered view is 'views/index/test'. With annotations (for example, '/char/any-char-name') - indexAction in CharController matched and executed but 'views/char/index' view not rendered.
Is it expected behavior and I need to manually specify view in every action with $this->view->pick?