Last active
December 31, 2015 03:29
-
-
Save alexander-torosh/7927611 to your computer and use it in GitHub Desktop.
Phalcon ViewEngine Volt extended
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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