Hi, if we initialize two view services and register the view engines using the class name something goes wrong and we get not output. But if we return an instance of the service, then it works.
If we do like this, it doesn't work:
$di->set('view', function () use ($config) {
$view = new \Phalcon\Mvc\View();
$view->setViewsDir($config->application->viewsDir);
$view->registerEngines(array(
'.phtml' => 'Phalcon\Mvc\View\Engine\Php',
'.volt' => 'Phalcon\Mvc\View\Engine\Volt'
));
return $view;
}, true);
$di->set('simpleView', function() use ($config) {
$view = new Phalcon\Mvc\View\Simple();
$view->setViewsDir($config->application->viewsDir);
$view->registerEngines(array(
".phtml" => "Phalcon\Mvc\View\Engine\Php",
".volt" => "Phalcon\Mvc\View\Engine\Volt"
));
return $view;
});
More specifically, it's doesn't work when the engines are registered using the class name in BOTH services. If one uses classnames and the other doesn't, then it works. This works all the time:
$di->set('view', function () use ($config) {
$view = new \Phalcon\Mvc\View();
$view->setViewsDir($config->application->viewsDir);
$view->registerEngines(array(
'.phtml' => function ($view, $di) use ($config) {
$phtml = new \Phalcon\Mvc\View\Engine\Php($view, $di);
return $phtml;
},
'.volt' => function ($view, $di) use ($config) {
$volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di);
return $volt;
}
));
return $view;
}, true);
$di->set('simpleView', function() use ($config) {
$view = new Phalcon\Mvc\View\Simple();
$view->setViewsDir($config->application->viewsDir);
$view->registerEngines(array(
'.phtml' => function ($view, $di) use ($config) {
$phtml = new \Phalcon\Mvc\View\Engine\Php($view, $di);
return $phtml;
},
'.volt' => function ($view, $di) use ($config) {
$volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di);
return $volt;
}
));
return $view;
});
Any ideas?