vendor/store.shopware.com/spnonewslettereconomy/src/Subscriber/NewsletterDispatcherSubscriber.php line 30

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. /*
  3.  * (c) webpiloten. <kontakt@web-piloten.de>
  4.  * For the full copyright and license information, please view the LICENSE
  5.  * file that was distributed with this source code.
  6.  */
  7. namespace Spno\NewsletterEconomy\Subscriber;
  8. use Spno\NewsletterEconomy\Event\NewsletterDispatcherExceptionEvent;
  9. use Spno\NewsletterEconomy\Service\Newsletter\NewsletterStatistics;
  10. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  11. class NewsletterDispatcherSubscriber implements EventSubscriberInterface
  12. {
  13.     private NewsletterStatistics $newsletterStatistics;
  14.     public function __construct(NewsletterStatistics $newsletterStatistics)
  15.     {
  16.         $this->newsletterStatistics $newsletterStatistics;
  17.     }
  18.     public static function getSubscribedEvents(): array
  19.     {
  20.         return [
  21.             NewsletterDispatcherExceptionEvent::class => 'onNewsletterDispatcherException',
  22.         ];
  23.     }
  24.     public function onNewsletterDispatcherException(NewsletterDispatcherExceptionEvent $event): void
  25.     {
  26.         $newsletter $event->getNewsletter();
  27.         $recipient $event->getRecipient();
  28.         $this->newsletterStatistics->createRecipientFailed(
  29.             $newsletter->getId(),
  30.             $recipient->getId()
  31.         );
  32.     }
  33. }