You are here

public function MandrillService::getMailSystems in Mandrill 8

Get the mail systems defined in the mail system module.

Return value

array Array of mail systems and keys

  • key Either the module-key or default for site wide system.
  • sender The class to use for sending mail.
  • formatter The class to use for formatting mail.

Overrides MandrillServiceInterface::getMailSystems

File

src/MandrillService.php, line 58

Class

MandrillService
Mandrill Service.

Namespace

Drupal\mandrill

Code

public function getMailSystems() {
  $systems = [];

  // Check if the system wide sender or formatter is Mandrill.
  $mailSystemConfig = $this->config
    ->get('mailsystem.settings');
  $systems[] = [
    'key' => 'default',
    'sender' => $mailSystemConfig
      ->get('defaults')['sender'],
    'formatter' => $mailSystemConfig
      ->get('defaults')['formatter'],
  ];

  // Check all custom configured modules if any uses Mandrill.
  $modules = $mailSystemConfig
    ->get('modules') ?: [];
  foreach ($modules as $module => $configuration) {
    foreach ($configuration as $key => $settings) {
      $systems[] = [
        'key' => "{$module}-{$key}",
        'sender' => $settings['sender'],
        'formatter' => $settings['formatter'],
      ];
    }
  }
  return $systems;
}