From de4c761e8810c7ca76f6e7bf53713546558491b0 Mon Sep 17 00:00:00 2001 From: Awilum Date: Wed, 20 Mar 2019 10:59:56 +0300 Subject: [PATCH] Flextype Core: Global Vars Twig Extension - added --- flextype/bootstrap.php | 3 ++ flextype/twig/GlobalVarsTwigExtension.php | 37 +++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 flextype/twig/GlobalVarsTwigExtension.php diff --git a/flextype/bootstrap.php b/flextype/bootstrap.php index 3b3ac93a..6b90b95b 100755 --- a/flextype/bootstrap.php +++ b/flextype/bootstrap.php @@ -300,6 +300,9 @@ $flextype['view'] = function ($container) { // Add Csrf Twig Extension $view->addExtension(new CsrfTwigExtension($container->get('csrf'))); + // Add Global Vars Twig Extension + $view->addExtension(new GlobalVarsTwigExtension($container)); + // Return view return $view; }; diff --git a/flextype/twig/GlobalVarsTwigExtension.php b/flextype/twig/GlobalVarsTwigExtension.php new file mode 100644 index 00000000..52fd9cc8 --- /dev/null +++ b/flextype/twig/GlobalVarsTwigExtension.php @@ -0,0 +1,37 @@ + + * @link http://romanenko.digital + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Flextype; + +class GlobalVarsTwigExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface +{ + /** + * Flextype Dependency Container + */ + private $flextype; + + /** + * Constructor + */ + public function __construct($flextype) + { + $this->flextype = $flextype; + } + + public function getGlobals() + { + return [ + 'flextype_version' => '0.9.0', + 'registry' => $this->flextype['registry']->dump() + ]; + } +}