|
15 | 15 |
|
16 | 16 | use Neos\Flow\Annotations as Flow;
|
17 | 17 | use Neos\Flow\Mvc\ActionResponse;
|
| 18 | +use Neos\Flow\ObjectManagement\ObjectManagerInterface; |
18 | 19 | use Neos\Flow\ResourceManagement\PersistentResource;
|
19 | 20 | use Neos\Fusion\Form\Runtime\Domain\Exception\ActionException;
|
20 | 21 | use Neos\SymfonyMailer\Service\MailerService;
|
|
28 | 29 | class EmailAction extends AbstractAction
|
29 | 30 | {
|
30 | 31 | #[Flow\Inject]
|
31 |
| - protected MailerService $mailerService; |
| 32 | + protected ObjectManagerInterface $objectManager; |
32 | 33 |
|
33 | 34 | /**
|
34 | 35 | * @return ActionResponse|null
|
35 | 36 | * @throws ActionException
|
36 | 37 | */
|
37 | 38 | public function perform(): ?ActionResponse
|
38 | 39 | {
|
| 40 | + if (!class_exists(MailerService::class)) { |
| 41 | + throw new ActionException('The "neos/symfonymailer" doesn\'t seem to be installed, but is required for the EmailAction to work!', 1503392532); |
| 42 | + } |
| 43 | + |
39 | 44 | $subject = $this->options['subject'] ?? null;
|
40 | 45 | $text = $this->options['text'] ?? null;
|
41 | 46 | $html = $this->options['html'] ?? null;
|
@@ -119,7 +124,7 @@ public function perform(): ?ActionResponse
|
119 | 124 | );
|
120 | 125 | return $response;
|
121 | 126 | } else {
|
122 |
| - $this->mailerService->getMailer()->send($mail); |
| 127 | + $this->getMailerService()->getMailer()->send($mail); |
123 | 128 | }
|
124 | 129 |
|
125 | 130 | return null;
|
@@ -154,4 +159,11 @@ protected function addAttachments(Email $mail): void
|
154 | 159 | }
|
155 | 160 | }
|
156 | 161 | }
|
| 162 | + |
| 163 | + private function getMailerService(): MailerService |
| 164 | + { |
| 165 | + /** @var MailerService $mailerService */ |
| 166 | + $mailerService = $this->objectManager->get(MailerService::class); |
| 167 | + return $mailerService; |
| 168 | + } |
157 | 169 | }
|
0 commit comments