custom/plugins/ProcWegmannTheme/src/Subscriber/MaintenanceSubscriber.php line 25

Open in your IDE?
  1. <?php
  2. namespace Proclane\WegmannTheme\Subscriber;
  3. use Proclane\WegmannTheme\Service\ConfigService;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. use Shopware\Storefront\Event\StorefrontRenderEvent;
  6. class MaintenanceSubscriber implements EventSubscriberInterface
  7. {
  8.     private ConfigService $configService;
  9.     public function __construct(ConfigService $configService)
  10.     {
  11.         $this->configService $configService;
  12.     }
  13.     public static function getSubscribedEvents(): array
  14.     {
  15.         return [
  16.             StorefrontRenderEvent::class => 'onStorefrontRender'
  17.         ];
  18.     }
  19.     public function onStorefrontRender(StorefrontRenderEvent $event): void
  20.     {
  21.         $salesChannelId $event->getSalesChannelContext()->getSalesChannel()->getId();
  22.         if(!$this->configService->isPseudoMaintenanceModeActive($salesChannelId)) return;
  23.         $event->setParameter('pseudoMaintenance', [
  24.             'active'   => $this->configService->isPseudoMaintenanceModeActive($salesChannelId),
  25.             'before'   => $this->configService->isBeforeStartDate($salesChannelId),
  26.             'inProgress' => $this->configService->isInProgress($salesChannelId),
  27.             'after'    => $this->configService->isAfterEndDate($salesChannelId),
  28.         ]);
  29.     }
  30. }