<?php
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Scripting/PHPClass.php to edit this template
*/
namespace NextGen\ApexTemplateBundle\Listener;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
/**
* Description of ThemeListener
*
* @author guest
*/
class ThemeListener
{
const LAYOUT_MODE = 'layout_mode';
/**
*
* @var ContainerInterface
*/
private $configs;
public function __construct(ParameterBagInterface $container)
{
$this->configs = $container->get("apex_template");
}
public function onKernelResponse(ResponseEvent $event)
{
if ($event->getRequest()->cookies->has(self::LAYOUT_MODE)) {
return;
}
$cookie = Cookie::create(self::LAYOUT_MODE)
->withValue($this->configs["theme"][self::LAYOUT_MODE])
->withSecure(false)
->withHttpOnly(false);
$event->getResponse()->headers->setCookie($cookie);
}
}