parent
850503a5b4
commit
698c48feab
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
@ -0,0 +1,55 @@ |
|||||||
|
<?php |
||||||
|
/* For licensing terms, see /license.txt */ |
||||||
|
|
||||||
|
namespace Chamilo\ThemeBundle\EventListener; |
||||||
|
|
||||||
|
use Chamilo\CoreBundle\Framework\Container; |
||||||
|
use Symfony\Component\DependencyInjection\ContainerAwareTrait; |
||||||
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
||||||
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
||||||
|
use Symfony\Component\HttpKernel\Event\FilterControllerEvent; |
||||||
|
use Symfony\Component\HttpKernel\Event\FilterResponseEvent; |
||||||
|
use Symfony\Component\HttpKernel\Event\GetResponseEvent; |
||||||
|
use Symfony\Component\HttpKernel\KernelEvents; |
||||||
|
use Symfony\Component\Routing\Route; |
||||||
|
|
||||||
|
class TwigListener implements EventSubscriberInterface |
||||||
|
{ |
||||||
|
public function __construct(ContainerInterface $container) |
||||||
|
{ |
||||||
|
$this->container = $container; |
||||||
|
} |
||||||
|
|
||||||
|
use ContainerAwareTrait; |
||||||
|
|
||||||
|
/** |
||||||
|
* @param GetResponseEvent $event |
||||||
|
*/ |
||||||
|
public function onKernelRequest(GetResponseEvent $event) |
||||||
|
{ |
||||||
|
if (!$event->isMasterRequest()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
$container = $this->container; |
||||||
|
|
||||||
|
Container::setContainer($container); |
||||||
|
Container::setLegacyServices($container); |
||||||
|
|
||||||
|
$theme = api_get_visual_theme(); |
||||||
|
$twig = $container->get('twig'); |
||||||
|
$twig->addGlobal('favico', \Template::getPortalIcon($theme)); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @return array |
||||||
|
*/ |
||||||
|
public static function getSubscribedEvents() |
||||||
|
{ |
||||||
|
return [ |
||||||
|
// must be registered before the default Locale listener |
||||||
|
KernelEvents::REQUEST => [['onKernelRequest', 15]], |
||||||
|
]; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -1,14 +1,5 @@ |
|||||||
services: |
#services: |
||||||
_defaults: |
# chamilo_theme_widget_extension: |
||||||
autowire: true |
# class: 'Chamilo\ThemeBundle\Twig\WidgetExtension' |
||||||
|
# tags: |
||||||
Chamilo\ThemeBundle\Controller\ExceptionController: |
# - 'twig.extension' |
||||||
public: true |
|
||||||
arguments: |
|
||||||
$twig: '@twig' |
|
||||||
$debug: '%kernel.debug%' |
|
||||||
|
|
||||||
chamilo_theme_widget_extension: |
|
||||||
class: 'Chamilo\ThemeBundle\Twig\WidgetExtension' |
|
||||||
tags: |
|
||||||
- 'twig.extension' |
|
||||||
|
|||||||
Loading…
Reference in new issue