protected function addFunction_includeAssets()
{
$includeAssetsFunction = new Twig_SimpleFunction('includeAssets', function ($params) {
if (!isset($params['type'])) {
throw new Exception("The function includeAssets needs a 'type' parameter.");
}
$assetType = strtolower($params['type']);
switch ($assetType) {
case 'css':
return AssetManager::getInstance()->getCssInclusionDirective();
case 'js':
return AssetManager::getInstance()->getJsInclusionDirective();
default:
throw new Exception("The twig function includeAssets 'type' parameter needs to be either 'css' or 'js'.");
}
});
$this->twig->addFunction($includeAssetsFunction);
}