custom/plugins/api-flow-trigger-plugin-sw6/src/Core/Content/ApiFlowTrigger/MailErrorSubscriber.php line 27

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Applifaction\AppliApiFlowTrigger\Core\Content\ApiFlowTrigger;
  4. use Shopware\Core\Content\MailTemplate\Service\Event\MailErrorEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class MailErrorSubscriber implements EventSubscriberInterface
  7. {
  8.     protected ?string $lastErrorMessage;
  9.     public function __construct()
  10.     {
  11.         $this->lastErrorMessage null;
  12.     }
  13.     public static function getSubscribedEvents(): array
  14.     {
  15.         return [
  16.             'Shopware\Core\Content\MailTemplate\Service\Event\MailErrorEvent' => 'onMailError'
  17.         ];
  18.     }
  19.     public function onMailError(MailErrorEvent $event)
  20.     {
  21.         $this->lastErrorMessage $event->getMessage();
  22.     }
  23.     public function hasRecordedError(): bool
  24.     {
  25.         return !is_null($this->lastErrorMessage);
  26.     }
  27.     public function getLastErrorMessage() {
  28.         return $this->lastErrorMessage;
  29.     }
  30.     public function clearRecordedError() {
  31.         $this->lastErrorMessage null;
  32.     }
  33. }