Skip to content

Instantly share code, notes, and snippets.

@alexander-torosh
Last active December 31, 2015 03:29
Show Gist options
  • Select an option

  • Save alexander-torosh/7927611 to your computer and use it in GitHub Desktop.

Select an option

Save alexander-torosh/7927611 to your computer and use it in GitHub Desktop.
Phalcon ViewEngine Volt extended
namespace Application\Mvc\ViewEngine;
class Volt extends \Phalcon\Mvc\View\Engine\Volt
{
public function __construct($view, $dependencyInjector = null)
{
parent::__construct($view, $dependencyInjector);
}
public function initCompiler()
{
$compiler = $this->getCompiler();
$compiler->addFunction('const', function($resolvedArgs) {
return "get_defined_constants()[$resolvedArgs]";
});
$compiler->addFunction('suffix', function() {
return "LANG_SUFFIX";
});
$compiler->addFunction('helper', function() {
return '(new Application\Mvc\Helper())';
});
$compiler->addFunction('translate', function($resolvedArgs) {
return '$this->helper->translate(' . $resolvedArgs . ')';
});
$compiler->addFunction('langUrl', function($resolvedArgs) {
return '$this->helper->langUrl(' . $resolvedArgs . ')';
});
$compiler->addFunction('imageHtml', function($resolvedArgs) {
return '(new \Image\Filter(' . $resolvedArgs . '))->imageHtml()';
});
$compiler->addFunction('imageSrc', function($resolvedArgs) {
return '(new \Image\Filter(' . $resolvedArgs . '))->cachedRelPath()';
});
$compiler->addFunction('widget', function($resolvedArgs) {
return '(new \Application\Widget\Proxy(' . $resolvedArgs . '))';
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment