summaryrefslogtreecommitdiff
path: root/src/Renderer/Twig/Extensions/Globals.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Renderer/Twig/Extensions/Globals.php')
-rw-r--r--src/Renderer/Twig/Extensions/Globals.php16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/Renderer/Twig/Extensions/Globals.php b/src/Renderer/Twig/Extensions/Globals.php
index f9bffbc8..ef29a819 100644
--- a/src/Renderer/Twig/Extensions/Globals.php
+++ b/src/Renderer/Twig/Extensions/Globals.php
@@ -2,11 +2,23 @@
namespace Engelsystem\Renderer\Twig\Extensions;
+use Engelsystem\Helpers\Authenticator;
use Twig_Extension as TwigExtension;
use Twig_Extension_GlobalsInterface as GlobalsInterface;
class Globals extends TwigExtension implements GlobalsInterface
{
+ /** @var Authenticator */
+ protected $auth;
+
+ /**
+ * @param Authenticator $auth
+ */
+ public function __construct(Authenticator $auth)
+ {
+ $this->auth = $auth;
+ }
+
/**
* Returns a list of global variables to add to the existing list.
*
@@ -14,10 +26,10 @@ class Globals extends TwigExtension implements GlobalsInterface
*/
public function getGlobals()
{
- global $user;
+ $user = $this->auth->user();
return [
- 'user' => isset($user) ? $user : [],
+ 'user' => $user ? $user : [],
];
}
}