blob: ef29a819595886f932127b70694d6519f1c60e02 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
<?php
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.
*
* @return array An array of global variables
*/
public function getGlobals()
{
$user = $this->auth->user();
return [
'user' => $user ? $user : [],
];
}
}
|