-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Mailer] Fix rendered templates for notifications #48505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,18 @@ public function getContext(): array | |
return $this->context; | ||
} | ||
|
||
public function isRendered(): bool | ||
{ | ||
return null === $this->htmlTemplate && null === $this->textTemplate; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not using a boolean property as done in the other class? |
||
} | ||
|
||
public function markAsRendered(): void | ||
{ | ||
$this->textTemplate = null; | ||
$this->htmlTemplate = null; | ||
$this->context = []; | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,7 @@ public function send(RawMessage $message, Envelope $envelope = null): ?SentMessa | |
$envelope = $event->getEnvelope(); | ||
$message = $event->getMessage(); | ||
|
||
if ($message instanceof TemplatedEmail && ($message->getTextTemplate() || $message->getHtmlTemplate())) { | ||
if ($message instanceof TemplatedEmail && !$message->isRendered()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The behavior seems different here now, the error may be that the template has already been rendered. |
||
throw new LogicException(sprintf('You must configure a "%s" when a "%s" instance has a text or HTML template set.', BodyRendererInterface::class, get_debug_type($message))); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is worth adding a comment as done two lines below or should it be updated to cover this new case?