src/Offer/EventSubscriber/UpdateOfferStatusSubscriber.php line 44

  1. <?php
  2. declare(strict_types=1);
  3. /**
  4.  * Copyright (c) 2021 TECLA Consulting Group oü.
  5.  * All rights reserved.
  6.  *
  7.  * This unpublished material is proprietary to TECLA Consulting Group oü.
  8.  * All rights reserved. The methods and
  9.  * techniques described herein are considered trade secrets
  10.  * and/or confidential. Reproduction or distribution, in whole
  11.  * or in part, is forbidden except by express written permission
  12.  * of TECLA Consulting Group oü.
  13.  *
  14.  * @author    Matúš Sýkorjak <matus@tecla.no>
  15.  * @copyright 2021 TECLA Consulting Group oü
  16.  */
  17. namespace App\Offer\EventSubscriber;
  18. use App\Offer\Enum\OfferStatus;
  19. use App\Offer\Event\OfferEmail\SentEvent;
  20. use App\Offer\Service\OfferServiceInterface;
  21. use JetBrains\PhpStorm\ArrayShape;
  22. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  23. final class UpdateOfferStatusSubscriber implements EventSubscriberInterface
  24. {
  25.     private OfferServiceInterface $service;
  26.     public function __construct(OfferServiceInterface $service)
  27.     {
  28.         $this->service $service;
  29.     }
  30.     #[ArrayShape([SentEvent::class => 'array'])]
  31.     public static function getSubscribedEvents(): array
  32.     {
  33.         return [
  34.             SentEvent::class => ['onSent'0],
  35.         ];
  36.     }
  37.     public function onSent(SentEvent $event): void
  38.     {
  39.         $this->service->updateStatus($event->getEmail()->getOffer(), OfferStatus::SENT());
  40.     }
  41. }