Skip to content

Commit

Permalink
Merge pull request #20 from LordSimal/master
Browse files Browse the repository at this point in the history
fix PHP7.4 error due to wrong config implementation in EmailFactory
  • Loading branch information
I-Valchev authored Oct 22, 2020
2 parents b9090ad + 198a8c8 commit 42a4050
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 42a4050

Please sign in to comment.