You are here

function mailsystem_get_mail_theme in Mail System 8.4

Same name and namespace in other branches
  1. 8.2 mailsystem.module \mailsystem_get_mail_theme()
  2. 6.2 mailsystem.module \mailsystem_get_mail_theme()
  3. 7.3 mailsystem.module \mailsystem_get_mail_theme()
  4. 7.2 mailsystem.module \mailsystem_get_mail_theme()

Retrieves the key of the theme used to render the emails.

@todo Add some kind of hook to let other modules alter this behavior.

File

./mailsystem.module, line 15
Provide UI for controlling the mail_system variable.

Code

function mailsystem_get_mail_theme() {
  $theme_key = \Drupal::theme()
    ->getActiveTheme()
    ->getName();
  $config = \Drupal::config('mailsystem.settings');
  $theme_config = \Drupal::config('system.theme');
  $theme = $config
    ->get('theme');
  switch ($theme) {
    case 'default':
      $theme = $theme_config
        ->get('default');
      break;
    case 'current':
      $theme = $theme_key;
      break;
    case 'domain':

      // Fetch the theme for the current domain.
      // @todo: Reimplement this as soon as module port or similar module is around.
      if (FALSE && \Drupal::moduleHandler()
        ->moduleExists('domain_theme')) {

        // Assign the selected theme, based on the active domain.
        global $_domain;
        $domain_theme = domain_theme_lookup($_domain['domain_id']);

        // The above returns -1 on failure.
        $theme = $domain_theme != -1 ? $domain_theme['theme'] : $theme_key;
      }
      break;
  }
  return $theme;
}