From 198a8c83992133c6f35a4fc5649fff2659cb00a5 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Tue, 20 Oct 2020 21:30:32 +0200 Subject: [PATCH] fix PHP7.4 error due to wrong config implementation in EmailFactory --- src/EventSubscriber/Mailer.php | 2 +- src/Factory/EmailFactory.php | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/EventSubscriber/Mailer.php b/src/EventSubscriber/Mailer.php index 0a7fed9..7a313e9 100644 --- a/src/EventSubscriber/Mailer.php +++ b/src/EventSubscriber/Mailer.php @@ -65,7 +65,7 @@ public function buildEmail(): TemplatedEmail { $meta = $this->event->getMeta(); - $email = (new EmailFactory())->create($this->event->getFormConfig(), $this->event->getForm(), $meta); + $email = (new EmailFactory())->create($this->event->getFormConfig(), $this->event->getConfig(), $this->event->getForm(), $meta); if ($this->event->isSpam()) { $subject = Str::ensureStartsWith($email->getSubject(), '[SPAM] '); diff --git a/src/Factory/EmailFactory.php b/src/Factory/EmailFactory.php index c4d86b8..3855b07 100644 --- a/src/Factory/EmailFactory.php +++ b/src/Factory/EmailFactory.php @@ -21,13 +21,19 @@ class EmailFactory /** @var Collection */ private $notification; - public function create(Collection $config, Form $form, array $meta = []): TemplatedEmail + /** + * @param Collection $formConfig The config specific for the current form + * @param Collection $config The global config defined config/extensions/bolt-boltforms.yaml + * @param Form $form The form object + * @param array $meta Metadata of the PostSubmitEvent + */ + public function create(Collection $formConfig, Collection $config, Form $form, array $meta = []): TemplatedEmail { $this->config = $config; - $this->notification = collect($config->get('notification', [])); + $this->notification = collect($formConfig->get('notification', [])); $this->form = $form; - $debug = (bool) $config->get('debug')['enabled']; + $debug = (bool) $this->config->get('debug')['enabled']; $email = (new TemplatedEmail()) ->from($this->getFrom()) @@ -38,7 +44,7 @@ public function create(Collection $config, Form $form, array $meta = []): Templa 'data' => $form->getData(), 'formname' => $form->getName(), 'meta' => $meta, - 'config' => $config, + 'config' => $formConfig, ]); if (self::hasCc()) {