mirror of
https://github.com/flextype/flextype.git
synced 2025-08-15 09:34:14 +02:00
Flextype Core: Global Vars Twig Extension - added
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
37
flextype/twig/GlobalVarsTwigExtension.php
Normal file
37
flextype/twig/GlobalVarsTwigExtension.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Flextype
|
||||
*
|
||||
* @author Sergey Romanenko <hello@romanenko.digital>
|
||||
* @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()
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user