You are here

public function MailsystemManager::getMailTheme in Mail System 8.4

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

1 call to MailsystemManager::getMailTheme()
MailsystemManager::mail in src/MailsystemManager.php
Composes and optionally sends an email message.

File

src/MailsystemManager.php, line 153

Class

MailsystemManager
Factory for creating mail system objects based on BasePlugin's.

Namespace

Drupal\mailsystem

Code

public function getMailTheme() {
  $theme = $this->configFactory
    ->get('mailsystem.settings')
    ->get('theme');
  switch ($theme) {
    case 'default':
      $theme = $this->configFactory
        ->get('system.theme')
        ->get('default');
      break;
    case 'current':
      $theme = $this->themeManager
        ->getActiveTheme()
        ->getName();
      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'] : $this->themeManager
          ->getActiveTheme()
          ->getName();
      }
      break;
  }
  return $theme;
}