Archived
1
0
Fork 0

app/config/services.php: adding template service.

This commit is contained in:
Henrik Hautakoski 2018-06-12 23:32:03 +02:00
parent eb62be5d86
commit 823f6d2e3f
2 changed files with 20 additions and 0 deletions

View file

@ -4,6 +4,7 @@ application:
modelsDir : ../app/models/
migrationsDir : ../app/migrations/
viewsDir : ../app/views/
templateDir : ../app/templates/
listenersDir : ../app/listeners/
libraryDir : ../app/library/
formsDir : ../app/forms/

View file

@ -178,6 +178,25 @@ $di->setShared('view', function () use ($di, $config) {
return $view;
});
$di->set('template', function() use ($config) {
$view = new Phalcon\Mvc\View\Simple();
$view->setViewsDir($config->application->templateDir);
$view->registerEngines([
'.volt' => function ($view, $di) use ($config) {
$volt = new VoltEngine($view, $di);
$volt->setOptions(array(
'compiledPath' => $config->application->viewCacheDir,
'compiledSeparator' => '_',
));
return $volt;
},
'.phtml' => 'Phalcon\Mvc\View\Engine\Php'
]);
return $view;
});
$di->setShared('assets', function () {
$manager = new AssetsManager();