custom/plugins/EightworksCookieConsentPlus6/src/Service/AddDataToStorefront.php line 41

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Eightworks\EightworksCookieConsentPlus6\Service;
  3. /**
  4.  * \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  5.  *  ______ ________ _______ ______ __  __ _______
  6.  * |  __  |  |  |  |       |   __ \  |/  |     __|
  7.  * |  __  |  |  |  |   -   |      <     <|__     |
  8.  * |______|________|_______|___|__|__|\__|_______|
  9.  *
  10.  *  ####+++---   C  O  N  T  A  C  T   –--++++####
  11.  *
  12.  *  Internetagentur 8works
  13.  *  WEB: 8works.de
  14.  *  MAIL: info@8works.de
  15.  *
  16.  * \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  17.  **/
  18. use Shopware\Storefront\Pagelet\Footer\FooterPageletLoadedEvent;
  19. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  20. use Shopware\Core\Framework\Struct\ArrayEntity;
  21. use Symfony\Component\HttpFoundation\Request;
  22. class AddDataToStorefront implements EventSubscriberInterface
  23. {
  24.     public static function getSubscribedEvents(): array
  25.     {
  26.         return [
  27.             FooterPageletLoadedEvent::class => 'addCustomCookiesToStorefront'
  28.         ];
  29.     }
  30.     /**
  31.      * FooterPageletLoadedEvent
  32.      *
  33.      * @param FooterPageletLoadedEvent $event
  34.      * @return void
  35.      */
  36.     public function addCustomCookiesToStorefront(FooterPageletLoadedEvent $event): void
  37.     {
  38.         $request Request::createFromGlobals();
  39.         $cookies $request->cookies;
  40.         $event->getPagelet()->addExtension('customCookies', new ArrayEntity([
  41.             'cookieConsentPlusE1' => $cookies->get('cookie-consent-plus-e1'),
  42.             'cookieConsentPlusE2' => $cookies->get('cookie-consent-plus-e2')
  43.         ]));
  44.     }
  45. }