From 90f0db27d788b0d2e8f46dce5e29ddbf1dd1553b Mon Sep 17 00:00:00 2001 From: Awilum Date: Sat, 1 Jun 2019 14:59:02 +0300 Subject: [PATCH] Flextype Box Plugin: Admin #125 #117 - Global Vars added --- .../twig/GlobalVarsAdminTwigExtension.php | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 site/plugins/admin/twig/GlobalVarsAdminTwigExtension.php diff --git a/site/plugins/admin/twig/GlobalVarsAdminTwigExtension.php b/site/plugins/admin/twig/GlobalVarsAdminTwigExtension.php new file mode 100644 index 00000000..7c080616 --- /dev/null +++ b/site/plugins/admin/twig/GlobalVarsAdminTwigExtension.php @@ -0,0 +1,39 @@ + + * @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; + +use Flextype\Component\Session\Session; + +class GlobalVarsAdminTwigExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface +{ + /** + * Flextype Dependency Container + */ + private $flextype; + + /** + * Constructor + */ + public function __construct($flextype) + { + $this->flextype = $flextype; + } + + public function getGlobals() + { + return [ + 'is_logged' => ((Session::exists('role') && Session::get('role') == 'admin') ? true : false), + 'username' => Session::exists('username') ? Session::get('username') : '' + ]; + } +}