I've built a very simple module to learn how to integrate the swiftmailer module for sending emails that use a custom twig template.
A copy of the default swiftmailer twig template located here: http://cgit.drupalcode.org/swiftmailer/tree/templates/swiftmailer.html.twig was slightly modified and renamed following the instructions included within the file itself:
* This template may be overriden by module and/or mail key, using any of the
* following template names:
* - swiftmailer.html.twig: global, used by default.
* - swiftmailer--mymodule.html.twig: only emails sent by the module "mymodule".
* - swiftmailer--mymodule--test.html.twig: only emails by the module
* "mymodule" with key "test".
*
The name of the twig file is swiftmailer--emailtester.html.twig which is located within the active themes/mytheme/templates folder.
When I execute the call to send the email within the emailtester.module and walk through the calls being made within the ThemeManager.php, twig.engine.php, and Render.php files in Core, the template path points back to the/modules/contrib/swiftmailer/templates/swiftmailer.html.twig file and not to the /themes/mytheme/templates/swiftmailer--emailtester.html.twig file.
I've cleared my cache using drush cr as well as clear all caches within the config->performance section. I've also tried clearing the theme registry as well but nothing seems to make a difference as swiftmailer always falls back to using its global template file.
Any suggestions would be greatly appreciated.
cheers,
devin