Skip to content

Commit

Permalink
fix PHP7.4 error due to wrong config implementation in EmailFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
LordSimal committed Oct 20, 2020
1 parent b9090ad commit 198a8c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/EventSubscriber/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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] ');
Expand Down
14 changes: 10 additions & 4 deletions src/Factory/EmailFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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()) {
Expand Down

0 comments on commit 198a8c8

Please sign in to comment.