Loading src/BaseEmailInterface.php +0 −18 Changes for src/BaseEmailInterface.php: 0 added lines, 18 removed lines. Original line number Diff line number Diff line Loading @@ -22,24 +22,6 @@ use Symfony\Component\Mime\Header\Headers; */ interface BaseEmailInterface { /** * Sets the email subject. * * @param \Drupal\Component\Render\MarkupInterface|string $subject * The email subject. * * @return $this */ public function setSubject($subject); /** * Gets the email subject. * * @return \Drupal\Component\Render\MarkupInterface|string * The email subject, or NULL if not set. */ public function getSubject(); /** * Sets the sender address. * Loading src/BaseEmailTrait.php +0 −18 Changes for src/BaseEmailTrait.php: 0 added lines, 18 removed lines. Original line number Diff line number Diff line Loading @@ -16,13 +16,6 @@ trait BaseEmailTrait { */ protected $inner; /** * The email subject. * * @var \Drupal\Component\Render\MarkupInterface|string */ protected $subject; /** * The addresses. * Loading @@ -43,17 +36,6 @@ trait BaseEmailTrait { */ protected $sender; public function setSubject($subject) { // We must not force conversion of the subject to a string as this could // cause translation before switching to the correct language. $this->subject = $subject; return $this; } public function getSubject() { return $this->subject; } public function setSender($address) { $this->sender = Address::create($address); return $this; Loading src/Email.php +41 −0 Changes for src/Email.php: 41 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -75,6 +75,20 @@ class Email implements InternalEmailInterface { */ protected $body = []; /** * The email subject. * * @var \Drupal\Component\Render\MarkupInterface|string */ protected $subject; /** * Whether to replace variables in the email subject. * * @var bool */ protected $replaceSubject; /** * @var array */ Loading Loading @@ -284,6 +298,24 @@ class Email implements InternalEmailInterface { return $this->body; } /** * {@inheritdoc} */ public function setSubject($subject, bool $replace = FALSE) { // We must not force conversion of the subject to a string as this could // cause translation before switching to the correct language. $this->subject = $subject; $this->subjectReplace = $replace; return $this; } /** * {@inheritdoc} */ public function getSubject() { return $this->subject; } /** * {@inheritdoc} */ Loading Loading @@ -440,6 +472,15 @@ class Email implements InternalEmailInterface { $this->valid(self::PHASE_PRE_RENDER, self::PHASE_PRE_RENDER); // Render subject. if ($this->subjectReplace && $this->variables) { $subject = [ '#type' => 'inline_template', '#template' => $this->subject, '#context' => $this->variables, ]; $this->subject = $this->renderer->renderPlain($subject); } if ($this->subject instanceof MarkupInterface) { $this->subject = PlainTextOutput::renderFromHtml($this->subject); } Loading src/EmailInterface.php +20 −0 Changes for src/EmailInterface.php: 20 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -218,6 +218,26 @@ interface EmailInterface extends BaseEmailInterface { */ public function getBody(); /** * Sets the email subject. * * @param \Drupal\Component\Render\MarkupInterface|string $subject * The email subject. * @param bool $replace * (Optional) TRUE to replace variables in the email subject. * * @return $this */ public function setSubject($subject, bool $replace = FALSE); /** * Gets the email subject. * * @return \Drupal\Component\Render\MarkupInterface|string * The email subject, or NULL if not set. */ public function getSubject(); /** * Sets variables available in the email template. * Loading src/Plugin/EmailAdjuster/SubjectEmailAdjuster.php +1 −13 Changes for src/Plugin/EmailAdjuster/SubjectEmailAdjuster.php: 1 added line, 13 removed lines. Original line number Diff line number Diff line Loading @@ -22,19 +22,7 @@ class SubjectEmailAdjuster extends EmailAdjusterBase { */ public function build(EmailInterface $email) { $subject = $this->configuration['value']; if ($variables = $email->getVariables()) { // Apply TWIG template. $subject = [ '#type' => 'inline_template', '#template' => $subject, '#context' => $variables, ]; $renderer = \Drupal::service('renderer'); $subject = $renderer->renderPlain($subject); } $email->setSubject($subject); $email->setSubject($subject, TRUE); } /** Loading Loading
src/BaseEmailInterface.php +0 −18 Changes for src/BaseEmailInterface.php: 0 added lines, 18 removed lines. Original line number Diff line number Diff line Loading @@ -22,24 +22,6 @@ use Symfony\Component\Mime\Header\Headers; */ interface BaseEmailInterface { /** * Sets the email subject. * * @param \Drupal\Component\Render\MarkupInterface|string $subject * The email subject. * * @return $this */ public function setSubject($subject); /** * Gets the email subject. * * @return \Drupal\Component\Render\MarkupInterface|string * The email subject, or NULL if not set. */ public function getSubject(); /** * Sets the sender address. * Loading
src/BaseEmailTrait.php +0 −18 Changes for src/BaseEmailTrait.php: 0 added lines, 18 removed lines. Original line number Diff line number Diff line Loading @@ -16,13 +16,6 @@ trait BaseEmailTrait { */ protected $inner; /** * The email subject. * * @var \Drupal\Component\Render\MarkupInterface|string */ protected $subject; /** * The addresses. * Loading @@ -43,17 +36,6 @@ trait BaseEmailTrait { */ protected $sender; public function setSubject($subject) { // We must not force conversion of the subject to a string as this could // cause translation before switching to the correct language. $this->subject = $subject; return $this; } public function getSubject() { return $this->subject; } public function setSender($address) { $this->sender = Address::create($address); return $this; Loading
src/Email.php +41 −0 Changes for src/Email.php: 41 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -75,6 +75,20 @@ class Email implements InternalEmailInterface { */ protected $body = []; /** * The email subject. * * @var \Drupal\Component\Render\MarkupInterface|string */ protected $subject; /** * Whether to replace variables in the email subject. * * @var bool */ protected $replaceSubject; /** * @var array */ Loading Loading @@ -284,6 +298,24 @@ class Email implements InternalEmailInterface { return $this->body; } /** * {@inheritdoc} */ public function setSubject($subject, bool $replace = FALSE) { // We must not force conversion of the subject to a string as this could // cause translation before switching to the correct language. $this->subject = $subject; $this->subjectReplace = $replace; return $this; } /** * {@inheritdoc} */ public function getSubject() { return $this->subject; } /** * {@inheritdoc} */ Loading Loading @@ -440,6 +472,15 @@ class Email implements InternalEmailInterface { $this->valid(self::PHASE_PRE_RENDER, self::PHASE_PRE_RENDER); // Render subject. if ($this->subjectReplace && $this->variables) { $subject = [ '#type' => 'inline_template', '#template' => $this->subject, '#context' => $this->variables, ]; $this->subject = $this->renderer->renderPlain($subject); } if ($this->subject instanceof MarkupInterface) { $this->subject = PlainTextOutput::renderFromHtml($this->subject); } Loading
src/EmailInterface.php +20 −0 Changes for src/EmailInterface.php: 20 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -218,6 +218,26 @@ interface EmailInterface extends BaseEmailInterface { */ public function getBody(); /** * Sets the email subject. * * @param \Drupal\Component\Render\MarkupInterface|string $subject * The email subject. * @param bool $replace * (Optional) TRUE to replace variables in the email subject. * * @return $this */ public function setSubject($subject, bool $replace = FALSE); /** * Gets the email subject. * * @return \Drupal\Component\Render\MarkupInterface|string * The email subject, or NULL if not set. */ public function getSubject(); /** * Sets variables available in the email template. * Loading
src/Plugin/EmailAdjuster/SubjectEmailAdjuster.php +1 −13 Changes for src/Plugin/EmailAdjuster/SubjectEmailAdjuster.php: 1 added line, 13 removed lines. Original line number Diff line number Diff line Loading @@ -22,19 +22,7 @@ class SubjectEmailAdjuster extends EmailAdjusterBase { */ public function build(EmailInterface $email) { $subject = $this->configuration['value']; if ($variables = $email->getVariables()) { // Apply TWIG template. $subject = [ '#type' => 'inline_template', '#template' => $subject, '#context' => $variables, ]; $renderer = \Drupal::service('renderer'); $subject = $renderer->renderPlain($subject); } $email->setSubject($subject); $email->setSubject($subject, TRUE); } /** Loading