src/EventSubscriber/CookieSubscriber.php line 27

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by PhpStorm.
  4.  * User: admin
  5.  * Date: 17/07/2020
  6.  * Time: 10:01
  7.  *
  8.  * Copyright 2018-2019, RĂ©mi Fongaufier, All rights reserved.
  9.  */
  10. namespace App\EventSubscriber;
  11. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  12. use Symfony\Component\HttpKernel\Event\ControllerEvent;
  13. use Symfony\Component\HttpKernel\KernelEvents;
  14. class CookieSubscriber implements EventSubscriberInterface
  15. {
  16.     public static function getSubscribedEvents(): array
  17.     {
  18.         return [
  19.             KernelEvents::CONTROLLER => 'setCookiesStrategy'
  20.         ];
  21.     }
  22.     public function setCookiesStrategy(ControllerEvent $event)
  23.     {
  24.         $cookies $event->getRequest()->cookies->all();
  25.         if (array_key_exists('2tec2_rgpd_cookie'$cookies)) {
  26.             $cookie json_decode($cookies['2tec2_rgpd_cookie']);
  27.             $event->getRequest()->request->add(['cookie_acceptation' => $cookie->gtag]);
  28.         }
  29.     }
  30. }