<?php
namespace Proclane\WegmannTheme\Subscriber;
use Proclane\WegmannTheme\Service\ConfigService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Shopware\Storefront\Event\StorefrontRenderEvent;
class MaintenanceSubscriber implements EventSubscriberInterface
{
private ConfigService $configService;
public function __construct(ConfigService $configService)
{
$this->configService = $configService;
}
public static function getSubscribedEvents(): array
{
return [
StorefrontRenderEvent::class => 'onStorefrontRender'
];
}
public function onStorefrontRender(StorefrontRenderEvent $event): void
{
$salesChannelId = $event->getSalesChannelContext()->getSalesChannel()->getId();
if(!$this->configService->isPseudoMaintenanceModeActive($salesChannelId)) return;
$event->setParameter('pseudoMaintenance', [
'active' => $this->configService->isPseudoMaintenanceModeActive($salesChannelId),
'before' => $this->configService->isBeforeStartDate($salesChannelId),
'inProgress' => $this->configService->isInProgress($salesChannelId),
'after' => $this->configService->isAfterEndDate($salesChannelId),
]);
}
}