vendor/nextgen/apex-template-bundle/src/Listener/ThemeListener.php line 35

Open in your IDE?
  1. <?php
  2. /*
  3.  * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
  4.  * Click nbfs://nbhost/SystemFileSystem/Templates/Scripting/PHPClass.php to edit this template
  5.  */
  6. namespace NextGen\ApexTemplateBundle\Listener;
  7. use Symfony\Component\HttpFoundation\Cookie;
  8. use Symfony\Component\HttpKernel\Event\ResponseEvent;
  9. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  10. /**
  11.  * Description of ThemeListener
  12.  *
  13.  * @author guest
  14.  */
  15. class ThemeListener 
  16. {
  17.     
  18.     const LAYOUT_MODE 'layout_mode';
  19.     
  20.     /**
  21.      * 
  22.      * @var ContainerInterface
  23.      */
  24.     private $configs;
  25.     
  26.     public function __construct(ParameterBagInterface $container
  27.     {
  28.         $this->configs $container->get("apex_template");
  29.     }
  30.     
  31.     public function onKernelResponse(ResponseEvent $event)
  32.     {
  33.         if ($event->getRequest()->cookies->has(self::LAYOUT_MODE)) {
  34.             
  35.             return;
  36.         }
  37.         
  38.         $cookie Cookie::create(self::LAYOUT_MODE)
  39.             ->withValue($this->configs["theme"][self::LAYOUT_MODE])
  40.             ->withSecure(false)
  41.             ->withHttpOnly(false);
  42.         
  43.         $event->getResponse()->headers->setCookie($cookie);
  44.     }
  45.     
  46. }