| @@ 14-51 (lines=38) @@ | ||
| 11 | use Netgen\InformationCollection\API\Mailer\MailerInterface; |
|
| 12 | use Netgen\InformationCollection\API\Value\Event\InformationCollected; |
|
| 13 | ||
| 14 | class AutoResponderAction implements ActionInterface |
|
| 15 | { |
|
| 16 | /** |
|
| 17 | * @var \Netgen\InformationCollection\API\Mailer\MailerInterface |
|
| 18 | */ |
|
| 19 | protected $mailer; |
|
| 20 | ||
| 21 | /** |
|
| 22 | * @var \Netgen\InformationCollection\Core\Factory\AutoResponderDataFactory |
|
| 23 | */ |
|
| 24 | protected $factory; |
|
| 25 | ||
| 26 | /** |
|
| 27 | * AutoResponderAction constructor. |
|
| 28 | * |
|
| 29 | * @param \Netgen\InformationCollection\Core\Factory\AutoResponderDataFactory $factory |
|
| 30 | * @param \Netgen\InformationCollection\API\Mailer\MailerInterface $mailer |
|
| 31 | */ |
|
| 32 | public function __construct(AutoResponderDataFactory $factory, MailerInterface $mailer) |
|
| 33 | { |
|
| 34 | $this->mailer = $mailer; |
|
| 35 | $this->factory = $factory; |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * {@inheritdoc} |
|
| 40 | */ |
|
| 41 | public function act(InformationCollected $event): void |
|
| 42 | { |
|
| 43 | $emailData = $this->factory->build($event); |
|
| 44 | ||
| 45 | try { |
|
| 46 | $this->mailer->createAndSendMessage($emailData); |
|
| 47 | } catch (EmailNotSentException $e) { |
|
| 48 | throw new ActionFailedException('auto_responder', $e->getMessage()); |
|
| 49 | } |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| @@ 14-51 (lines=38) @@ | ||
| 11 | use Netgen\InformationCollection\Core\Factory\EmailDataFactory; |
|
| 12 | use Netgen\InformationCollection\API\Mailer\MailerInterface; |
|
| 13 | ||
| 14 | class EmailAction implements ActionInterface |
|
| 15 | { |
|
| 16 | /** |
|
| 17 | * @var \Netgen\InformationCollection\API\Mailer\MailerInterface |
|
| 18 | */ |
|
| 19 | protected $mailer; |
|
| 20 | ||
| 21 | /** |
|
| 22 | * @var \Netgen\InformationCollection\Core\Factory\EmailDataFactory |
|
| 23 | */ |
|
| 24 | protected $factory; |
|
| 25 | ||
| 26 | /** |
|
| 27 | * EmailAction constructor. |
|
| 28 | * |
|
| 29 | * @param \Netgen\InformationCollection\Core\Factory\EmailDataFactory $factory |
|
| 30 | * @param \Netgen\InformationCollection\API\Mailer\MailerInterface $mailer |
|
| 31 | */ |
|
| 32 | public function __construct(EmailDataFactory $factory, MailerInterface $mailer) |
|
| 33 | { |
|
| 34 | $this->mailer = $mailer; |
|
| 35 | $this->factory = $factory; |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * {@inheritdoc} |
|
| 40 | */ |
|
| 41 | public function act(InformationCollected $event): void |
|
| 42 | { |
|
| 43 | $emailData = $this->factory->build($event); |
|
| 44 | ||
| 45 | try { |
|
| 46 | $this->mailer->createAndSendMessage($emailData); |
|
| 47 | } catch (EmailNotSentException $e) { |
|
| 48 | throw new ActionFailedException('email', $e->getMessage()); |
|
| 49 | } |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||