Skip to content
Snippets Groups Projects
Commit 3d0f60ff authored by Sven Decabooter's avatar Sven Decabooter Committed by Adam Shepherd
Browse files

Issue #3280322 by svendecabooter, trickfun, nojj, AdamPS, timbraeckman:...

Issue #3280322 by svendecabooter, trickfun, nojj, AdamPS, timbraeckman: LegacyEmailBuilder calls hook_mail() too early
parent 59e45c97
No related branches found
No related tags found
1 merge request!24Issue #3280322: Wrong order receipt template
......@@ -5,6 +5,7 @@ namespace Drupal\symfony_mailer_bc\Plugin\EmailBuilder;
use Drupal\Core\Mail\MailManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\symfony_mailer\EmailFactoryInterface;
use Drupal\symfony_mailer\EmailInterface;
use Drupal\symfony_mailer\Exception\SkipMailException;
use Drupal\symfony_mailer\Processor\EmailBuilderBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -52,6 +53,25 @@ class LegacyEmailBuilder extends EmailBuilderBase implements ContainerFactoryPlu
* {@inheritdoc}
*/
public function fromArray(EmailFactoryInterface $factory, array $message) {
return $factory->newModuleEmail($message['module'], $message['key'], $message);
}
/**
* {@inheritdoc}
*/
public function createParams(EmailInterface $email, array $legacy_message = NULL) {
assert($legacy_message != NULL);
$email->setParam('legacy_message', $legacy_message);
}
/**
* Reacts to preRender phase.
*
* @param \Drupal\symfony_mailer\EmailInterface $email
* The email to process.
*/
public function preRender(EmailInterface $email) {
$message = $email->getParam('legacy_message');
$message += [
'subject' => '',
'body' => [],
......@@ -67,9 +87,7 @@ class LegacyEmailBuilder extends EmailBuilderBase implements ContainerFactoryPlu
throw new SkipMailException('Send aborted by hook_mail().');
}
$email = $factory->newModuleEmail($message['module'], $message['key']);
$this->mailManager->emailFromArray($email, $message);
return $email;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment