Sending mail now passes the parent data set to the layout
Renamed conflicting variable message -> content Fixes #1070
This commit is contained in:
parent
ed56c866bc
commit
4e507823ea
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
use System\Models\MailLayout;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class DbSystemMailLayoutRename extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
foreach (MailLayout::all() as $layout) {
|
||||
try {
|
||||
$layout->content_html = preg_replace("/({{\s*message\s*[|]raw\s*}})/i", "{{ content|raw }}", $layout->content_html);
|
||||
$layout->content_text = preg_replace("/({{\s*message\s*[|]raw\s*}})/i", "{{ content|raw }}", $layout->content_text);
|
||||
$layout->forceSave();
|
||||
}
|
||||
catch (Exception $ex) {}
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -31,11 +31,11 @@ $html = '<html>
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
{{ message|raw }}
|
||||
{{ content|raw }}
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
$text = '{{ message|raw }}';
|
||||
$text = '{{ content|raw }}';
|
||||
|
||||
MailLayout::create([
|
||||
'is_locked' => true,
|
||||
|
|
@ -53,13 +53,13 @@ $html = '<html>
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
{{ message|raw }}
|
||||
{{ content|raw }}
|
||||
<hr />
|
||||
<p>This is an automatic message. Please do not reply to it.</p>
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
$text = '{{ message|raw }}
|
||||
$text = '{{ content|raw }}
|
||||
|
||||
|
||||
---
|
||||
|
|
|
|||
|
|
@ -124,9 +124,9 @@ class MailTemplate extends Model
|
|||
$html = $twig->render($template->content_html, $data);
|
||||
if ($template->layout) {
|
||||
$html = $twig->render($template->layout->content_html, [
|
||||
'message' => $html,
|
||||
'content' => $html,
|
||||
'css' => $template->layout->content_css
|
||||
]);
|
||||
] + (array) $data);
|
||||
}
|
||||
|
||||
$message->setBody($html, 'text/html');
|
||||
|
|
@ -137,7 +137,9 @@ class MailTemplate extends Model
|
|||
if (strlen($template->content_text)) {
|
||||
$text = $twig->render($template->content_text, $data);
|
||||
if ($template->layout) {
|
||||
$text = $twig->render($template->layout->content_text, ['message' => $text]);
|
||||
$text = $twig->render($template->layout->content_text, [
|
||||
'content' => $text
|
||||
] + (array) $data);
|
||||
}
|
||||
|
||||
$message->addPart($text, 'text/plain');
|
||||
|
|
|
|||
Loading…
Reference in New Issue