<?php declare(strict_types=1);
namespace Eightworks\EightworksCookieConsentPlus6\Service;
/**
* \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
* ______ ________ _______ ______ __ __ _______
* | __ | | | | | __ \ |/ | __|
* | __ | | | | - | < <|__ |
* |______|________|_______|___|__|__|\__|_______|
*
* ####+++--- C O N T A C T –--++++####
*
* Internetagentur 8works
* WEB: 8works.de
* MAIL: info@8works.de
*
* \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
**/
use Shopware\Storefront\Pagelet\Footer\FooterPageletLoadedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Shopware\Core\Framework\Struct\ArrayEntity;
use Symfony\Component\HttpFoundation\Request;
class AddDataToStorefront implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
FooterPageletLoadedEvent::class => 'addCustomCookiesToStorefront'
];
}
/**
* FooterPageletLoadedEvent
*
* @param FooterPageletLoadedEvent $event
* @return void
*/
public function addCustomCookiesToStorefront(FooterPageletLoadedEvent $event): void
{
$request = Request::createFromGlobals();
$cookies = $request->cookies;
$event->getPagelet()->addExtension('customCookies', new ArrayEntity([
'cookieConsentPlusE1' => $cookies->get('cookie-consent-plus-e1'),
'cookieConsentPlusE2' => $cookies->get('cookie-consent-plus-e2')
]));
}
}