Skip to content

Instantly share code, notes, and snippets.

@phalcon
Created November 1, 2012 04:16
Show Gist options
  • Save phalcon/3991682 to your computer and use it in GitHub Desktop.
Save phalcon/3991682 to your computer and use it in GitHub Desktop.
/**
* Initializes the view and Volt
*
* @param array $options
*/
protected function initView($options = array())
{
$config = $this->_di->get('config');
$di = $this->_di;
$this->_di->set(
'volt',
function($view, $di) use($config)
{
$volt = new Volt($view, $di);
$volt->setOptions(
array(
'compiledPath' => ROOT_PATH . $config->app->volt->path,
'compiledExtension' => $config->app->volt->extension,
'compiledSeparator' => $config->app->volt->separator,
'stat' => (bool) $config->app->volt->stat,
)
);
return $volt;
}
);
/**
* Setup the view service
*/
$this->_di->set(
'view',
function() use ($config, $di)
{
$view = new \Phalcon\Mvc\View();
$view->setViewsDir(ROOT_PATH . $config->app->path->views);
$view->registerEngines(array('.volt' => 'volt'));
return $view;
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment