π©π°Denmark FrittenKeeZ
@ExTexan I managed to get it working by manually rendering the twig files and parse the markup along to body within hook_mail.
$module_path = \Drupal::service('extension.list.module')->getPath('my_module');
$template = $module_path . '/templates/email-body--' . str_replace('_', '-', $key) . '.html.twig';
$markup = twig_render_template($template, ['message' => compact('params'), 'theme_hook_original' => 'email_body']);
$message['body'] = [$markup];
$message['format'] = 'text/html';
Then I added the wrapper template file which sole content is {{ body | raw }}
/**
* Implements hook_theme().
*/
function my_module_theme($existing, $type, $theme, $path) {
// Copied from email-wrap theme hook.
return [
'email_wrap__my_module' => [
'template' => 'email-wrap--my-module',
'variables' => [
'email' => NULL,
'body' => '',
'is_html' => TRUE,
],
],
];
}
π©π°Denmark FrittenKeeZ
Marking as fixed, because that's the limit of how much of my time I wish to give you for freeπ.
Seeing as the documentation is clearly lacking, both in terms of migrating from Swiftmailer and how to use Twig and custom params with the new EmailBuilder, I can't possible think of a reason why you would mark this as fixed - you might as well just close this issue as you don't seem interested in getting that functionality to work.