Last active
November 22, 2022 19:56
-
-
Save andriyun/f0902d5dcf7c8d5ffe9e1eb3f9531018 to your computer and use it in GitHub Desktop.
Revisions
-
andriyun revised this gist
Oct 11, 2018 . No changes.There are no files selected for viewing
-
andriyun created this gist
Oct 11, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ <?php /** * See original implementation http://cgit.drupalcode.org/mailsystem/tree/src/MailsystemManager.php#n60 */ // Switch the theme to the configured mail theme. $theme_manager = \Drupal::service('theme.manager'); $mail_theme = '[your theme name]'; $current_active_theme = $theme_manager->getActiveTheme(); if ($mail_theme && $mail_theme != $current_active_theme->getName()) { $theme_initialization = \Drupal::service('theme.initialization'); $theme_manager->setActiveTheme($theme_initialization->initTheme($mail_theme)); } try { // Do your actions here. // ..... } finally { // Revert the active theme, this is done inside a finally block so it is // executed even if an exception is thrown during sending a mail. if ($mail_theme != $current_active_theme->getName()) { $theme_manager->setActiveTheme($current_active_theme); } }