platform/src/Core/Content/Newsletter/Event/Subscriber/NewsletterRecipientDeletedSubscriber.php line 25

Open in your IDE?
  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 Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. use Symfony\Component\Messenger\MessageBusInterface;
  8. class NewsletterRecipientDeletedSubscriber implements EventSubscriberInterface
  9. {
  10.     private MessageBusInterface $messageBus;
  11.     public function __construct(MessageBusInterface $messageBus)
  12.     {
  13.         $this->messageBus $messageBus;
  14.     }
  15.     public static function getSubscribedEvents()
  16.     {
  17.         return [NewsletterEvents::NEWSLETTER_RECIPIENT_DELETED_EVENT => 'onNewsletterRecipientDeleted'];
  18.     }
  19.     public function onNewsletterRecipientDeleted(EntityDeletedEvent $event): void
  20.     {
  21.         $message = new NewsletterRecipientIndexingMessage($event->getIds(), null$event->getContext());
  22.         $message->setDeletedNewsletterRecipients(true);
  23.         $this->messageBus->dispatch($message);
  24.     }
  25. }