src/Core/Content/Newsletter/Event/Subscriber/NewsletterRecipientDeletedSubscriber.php line 33

  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Content\Newsletter\Event\Subscriber;
  3. use Shopware\Core\Content\Newsletter\DataAbstractionLayer\NewsletterRecipientIndexingMessage;
  4. use Shopware\Core\Content\Newsletter\NewsletterEvents;
  5. use Shopware\Core\Framework\DataAbstractionLayer\Event\EntityDeletedEvent;
  6. use Shopware\Core\Framework\Log\Package;
  7. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  8. use Symfony\Component\Messenger\MessageBusInterface;
  9. /**
  10.  * @internal
  11.  */
  12. #[Package('customer-order')]
  13. class NewsletterRecipientDeletedSubscriber implements EventSubscriberInterface
  14. {
  15.     /**
  16.      * @internal
  17.      */
  18.     public function __construct(private readonly MessageBusInterface $messageBus)
  19.     {
  20.     }
  21.     /**
  22.      * @return array<string, string|array{0: string, 1: int}|list<array{0: string, 1?: int}>>
  23.      */
  24.     public static function getSubscribedEvents(): array
  25.     {
  26.         return [NewsletterEvents::NEWSLETTER_RECIPIENT_DELETED_EVENT => 'onNewsletterRecipientDeleted'];
  27.     }
  28.     public function onNewsletterRecipientDeleted(EntityDeletedEvent $event): void
  29.     {
  30.         $message = new NewsletterRecipientIndexingMessage($event->getIds(), null$event->getContext());
  31.         $message->setDeletedNewsletterRecipients(true);
  32.         $this->messageBus->dispatch($message);
  33.     }
  34. }