<?php declare(strict_types=1);
namespace Meteor\AjaxVariant\Subscriber;
use Shopware\Core\System\SystemConfig\SystemConfigService;
use Shopware\Storefront\Pagelet\Footer\FooterPageletLoadedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ConfigSubscriber implements EventSubscriberInterface
{
/**
* @var SystemConfigService
*/
private $systemConfigService;
public function __construct(SystemConfigService $systemConfigService)
{
$this->systemConfigService = $systemConfigService;
}
public static function getSubscribedEvents(): array
{
return [
FooterPageletLoadedEvent::class => 'onFooterPageletLoadedEvent'
];
}
public function onFooterPageletLoadedEvent(FooterPageletLoadedEvent $event): void
{
$configuration = $this->systemConfigService->get(
'MeteorAjaxVariant.config',
$event->getSalesChannelContext()->getSalesChannel()->getId()
);
$event->getPagelet()->assign([
'meteorAjaxVariant' => $configuration,
]);
}
}