custom/plugins/TdsOrlob/src/Subscriber/StorefrontSubscriber.php line 22

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Tds\Orlob\Subscriber;
  3. use DateTime;
  4. use Shopware\Storefront\Event\StorefrontRenderEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class StorefrontSubscriber implements EventSubscriberInterface
  7. {
  8.     /**
  9.      * {@inheritDoc}
  10.      */
  11.     public static function getSubscribedEvents()
  12.     {
  13.         return [
  14.             StorefrontRenderEvent::class => 'onStorefrontRender'
  15.         ];
  16.     }
  17.     public function onStorefrontRender(StorefrontRenderEvent $event): void
  18.     {
  19.         $event->setParameter('seasonThreshold'$this->buildSeasonThreshold());
  20.         $event->setParameter('currentSeasonThreshold'$this->buildCurrenSeasonThreshold());
  21.     }
  22.     /**
  23.      * @return string
  24.      *
  25.      * @throws \Exception
  26.      */
  27.     private function buildSeasonThreshold()
  28.     {
  29.         $format date('Y-03-01'strtotime('+1 year'));
  30.         $date = new DateTime($format);
  31.         return $date->format('U');
  32.     }
  33.     /**
  34.      * @return string
  35.      *
  36.      * @throws \Exception
  37.      */
  38.     private function buildCurrenSeasonThreshold()
  39.     {
  40.         $format date('Y-03-01');
  41.         $date = new DateTime($format);
  42.         return $date->format('U');
  43.     }
  44. }