2019-12-23 02:09:54 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Framework\Twig;
|
|
|
|
|
|
|
|
use Framework\Session\SessionInterface;
|
|
|
|
|
|
|
|
class VariableExtension extends \Twig_Extension
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var SessionInterface
|
|
|
|
*/
|
|
|
|
private $session;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
//private $url;
|
|
|
|
|
|
|
|
public function __construct(SessionInterface $session)
|
|
|
|
{
|
|
|
|
$this->session = $session;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFunctions()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
new \Twig_SimpleFunction('affiche_username', [$this, 'affich_usrname']),
|
2019-12-29 03:03:50 +01:00
|
|
|
new \Twig_SimpleFunction('affiche_role', [$this, 'affich_role']),
|
|
|
|
new \Twig_SimpleFunction('affiche_mail', [$this, 'affich_mail'])
|
2019-12-23 02:09:54 +01:00
|
|
|
];
|
|
|
|
}
|
|
|
|
public function affich_role(): ?string
|
|
|
|
{
|
|
|
|
$retour_aff = $this->session->get('role') ?: '';
|
|
|
|
return $retour_aff;
|
|
|
|
}
|
|
|
|
public function affich_usrname(): ?string
|
|
|
|
{
|
|
|
|
$retour_aff = $this->session->get('username') ?: '';
|
|
|
|
return $retour_aff;
|
|
|
|
}
|
2019-12-29 03:03:50 +01:00
|
|
|
public function affich_mail(): ?string
|
|
|
|
{
|
|
|
|
$retour_aff = $this->session->get('email') ?: '';
|
|
|
|
return $retour_aff;
|
|
|
|
}
|
2019-12-23 02:09:54 +01:00
|
|
|
}
|