Skip to content

Commit

Permalink
[9.x] Add raw content property for mailables (#44703)
Browse files Browse the repository at this point in the history
* Add raw mailable content property

* Fix constructor signature

* Fixed style

* formatting

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
Xammie and taylorotwell authored Oct 25, 2022
1 parent 23195b4 commit c1f5c9e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Illuminate/Mail/Mailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -1655,6 +1655,10 @@ private function ensureContentIsHydrated()
$this->markdown($content->markdown);
}

if ($content->htmlString) {
$this->html($content->htmlString);
}

foreach ($content->with as $key => $value) {
$this->with($key, $value);
}
Expand Down
24 changes: 23 additions & 1 deletion src/Illuminate/Mail/Mailables/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ class Content
*/
public $markdown;

/**
* The pre-rendered HTML of the message.
*
* @var string|null
*/
public $htmlString;

/**
* The message's view data.
*
Expand All @@ -53,16 +60,18 @@ class Content
* @param string|null $text
* @param string|null $markdown
* @param array $with
* @param string|null $htmlString
*
* @named-arguments-supported
*/
public function __construct(string $view = null, string $html = null, string $text = null, $markdown = null, array $with = [])
public function __construct(string $view = null, string $html = null, string $text = null, $markdown = null, array $with = [], string $htmlString = null)
{
$this->view = $view;
$this->html = $html;
$this->text = $text;
$this->markdown = $markdown;
$this->with = $with;
$this->htmlString = $htmlString;
}

/**
Expand Down Expand Up @@ -115,6 +124,19 @@ public function markdown(string $view)
return $this;
}

/**
* Set the pre-rendered HTML for the message.
*
* @param string $html
* @return $this
*/
public function htmlString(string $html)
{
$this->htmlString = $html;

return $this;
}

/**
* Add a piece of view data to the message.
*
Expand Down

0 comments on commit c1f5c9e

Please sign in to comment.