<?php
declare(strict_types=1);
namespace Zeobv\VisibleDiscounts\Storefront\Subscriber;
use Shopware\Storefront\Event\StorefrontRenderEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Zeobv\VisibleDiscounts\Service\ConfigService;
use Zeobv\VisibleDiscounts\Struct\VisibleDiscountConfigStruct;
class StorefrontRendererSubscriber implements EventSubscriberInterface
{
private ConfigService $configService;
public function __construct(
ConfigService $configService
)
{
$this->configService = $configService;
}
/**
* @return array<string>
*/
public static function getSubscribedEvents(): array
{
return [
StorefrontRenderEvent::class => 'onStorefrontRender',
];
}
public function onStorefrontRender(StorefrontRenderEvent $event): void
{
$event->setParameter('zeobvVisibleDiscountConfig', new VisibleDiscountConfigStruct($this->configService, $event->getSalesChannelContext()));
}
}