Created
October 24, 2017 09:48
-
-
Save victorlapshev/b865325be244c8389a7815a641d7274a to your computer and use it in GitHub Desktop.
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
| <?php | |
| namespace Events; | |
| use Bitrix\Main\Event; | |
| use Bitrix\Main\EventResult; | |
| use Misc\TwigExtension; | |
| class Twig | |
| { | |
| public static function addTwigExtension(Event $e) | |
| { | |
| /** @var \Twig_Environment $engine */ | |
| $engine = $e->getParameter(0); | |
| //$engine->addExtension(new TwigExtension() ); | |
| $includeFile = new \Twig_SimpleFunction('includeFile', function ($file) { | |
| global $APPLICATION; | |
| ob_start(); | |
| $APPLICATION->IncludeFile(INCLUDE_PATH . $file . '.php'); | |
| return ob_get_clean(); | |
| }); | |
| $engine->addFunction('includeFile', $includeFile); | |
| return new EventResult(EventResult::SUCCESS, array($engine)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment