<?php
declare(strict_types=1);
namespace Applifaction\AppliApiFlowTrigger\Core\Content\ApiFlowTrigger;
use Shopware\Core\Content\MailTemplate\Service\Event\MailErrorEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class MailErrorSubscriber implements EventSubscriberInterface
{
protected ?string $lastErrorMessage;
public function __construct()
{
$this->lastErrorMessage = null;
}
public static function getSubscribedEvents(): array
{
return [
'Shopware\Core\Content\MailTemplate\Service\Event\MailErrorEvent' => 'onMailError'
];
}
public function onMailError(MailErrorEvent $event)
{
$this->lastErrorMessage = $event->getMessage();
}
public function hasRecordedError(): bool
{
return !is_null($this->lastErrorMessage);
}
public function getLastErrorMessage() {
return $this->lastErrorMessage;
}
public function clearRecordedError() {
$this->lastErrorMessage = null;
}
}