<?php
namespace AWCmsBundle\Twig\Extension;
use AWCmsBundle\Event\GlobalTwigVariableEvent;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Twig_Extension;
use Twig_Extension_GlobalsInterface;
class GlobalVariablesExtension extends Twig_Extension implements Twig_Extension_GlobalsInterface
{
private $eventDispatcher;
public function __construct(EventDispatcherInterface $eventDispatcher)
{
$this->eventDispatcher = $eventDispatcher;
}
public function getGlobals()
{
$event = new GlobalTwigVariableEvent();
$this->eventDispatcher->dispatch(GlobalTwigVariableEvent::TO_POPULATE_EVENT, $event);
return $event->getData();
}
}