diff options
Diffstat (limited to 'src/Renderer/Twig/Extensions/Globals.php')
-rw-r--r-- | src/Renderer/Twig/Extensions/Globals.php | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/Renderer/Twig/Extensions/Globals.php b/src/Renderer/Twig/Extensions/Globals.php new file mode 100644 index 00000000..f9bffbc8 --- /dev/null +++ b/src/Renderer/Twig/Extensions/Globals.php @@ -0,0 +1,23 @@ +<?php + +namespace Engelsystem\Renderer\Twig\Extensions; + +use Twig_Extension as TwigExtension; +use Twig_Extension_GlobalsInterface as GlobalsInterface; + +class Globals extends TwigExtension implements GlobalsInterface +{ + /** + * Returns a list of global variables to add to the existing list. + * + * @return array An array of global variables + */ + public function getGlobals() + { + global $user; + + return [ + 'user' => isset($user) ? $user : [], + ]; + } +} |