custom/plugins/NextagMail/src/Subscriber/MailSendSubscriber.php line 56

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Nextag\Mail\Subscriber;
  4. use Psr\Log\LoggerInterface;
  5. use Shopware\Core\Checkout\Document\DocumentService;
  6. use Shopware\Core\Content\Mail\Service\AbstractMailService;
  7. use Shopware\Core\Content\MailTemplate\Exception\MailEventConfigurationException;
  8. use Shopware\Core\Content\MailTemplate\Exception\SalesChannelNotFoundException;
  9. use Shopware\Core\Content\MailTemplate\MailTemplateActions;
  10. use Shopware\Core\Content\Media\MediaService;
  11. use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
  12. use Shopware\Core\Framework\DataAbstractionLayer\Exception\InconsistentCriteriaIdsException;
  13. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  14. use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
  15. use Symfony\Contracts\EventDispatcher\Event;
  16. class MailSendSubscriber implements EventSubscriberInterface
  17. {
  18.     public const ACTION_NAME MailTemplateActions::MAIL_TEMPLATE_MAIL_SEND_ACTION;
  19.     public const MAIL_CONFIG_EXTENSION 'mail-attachments';
  20.     public function __construct(
  21.         AbstractMailService $emailService,
  22.         EntityRepositoryInterface $mailTemplateRepository,
  23.         MediaService $mediaService,
  24.         EntityRepositoryInterface $mediaRepository,
  25.         EntityRepositoryInterface $documentRepository,
  26.         DocumentService $documentService,
  27.         LoggerInterface $logger,
  28.         EventDispatcherInterface $eventDispatcher
  29.     ) {
  30.         $this->mailTemplateRepository $mailTemplateRepository;
  31.         $this->mediaService $mediaService;
  32.         $this->mediaRepository $mediaRepository;
  33.         $this->documentRepository $documentRepository;
  34.         $this->documentService $documentService;
  35.         $this->logger $logger;
  36.         $this->emailService $emailService;
  37.         $this->eventDispatcher $eventDispatcher;
  38.     }
  39.     public static function getSubscribedEvents(): array
  40.     {
  41.         return [
  42.             self::ACTION_NAME => 'sendMail',
  43.         ];
  44.     }
  45.     /**
  46.      * @throws MailEventConfigurationException
  47.      * @throws SalesChannelNotFoundException
  48.      * @throws InconsistentCriteriaIdsException
  49.      */
  50.     public function sendMail(Event $event): void
  51.     {
  52.         $mailEvent $event->getEvent();
  53.         if ($mailEvent instanceof \Shopware\Core\Checkout\Cart\Event\CheckoutOrderPlacedEvent) {
  54.             $event->stopPropagation();
  55.         }
  56.     }
  57. }