You are here

class Adapter in Mail System 8.4

Provides an adapter to send emails.

Hierarchy

Expanded class hierarchy of Adapter

1 file declares its use of Adapter
AdapterTest.php in tests/src/Unit/AdapterTest.php

File

src/Adapter.php, line 10

Namespace

Drupal\mailsystem
View source
class Adapter implements MailInterface {

  /**
   * The mail plugin.
   *
   * @var \Drupal\Core\Mail\MailInterface
   */
  protected $instanceFormatter;

  /**
   * The mail plugin.
   *
   * @var \Drupal\Core\Mail\MailInterface
   */
  protected $instanceSender;

  /**
   * Constructor.
   *
   * @param \Drupal\Core\Mail\MailInterface $formatter
   *   The MailPlugin for formatting the email before sending.
   * @param \Drupal\Core\Mail\MailInterface $sender
   *   The MailPlugin for sending the email.
   */
  public function __construct(MailInterface $formatter, MailInterface $sender) {
    $this->instanceFormatter = $formatter;
    $this->instanceSender = $sender;
  }

  /**
   * {@inheritdoc}
   */
  public function format(array $message) {
    return $this->instanceFormatter
      ->format($message);
  }

  /**
   * {@inheritdoc}
   */
  public function mail(array $message) {
    return $this->instanceSender
      ->mail($message);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Adapter::$instanceFormatter protected property The mail plugin.
Adapter::$instanceSender protected property The mail plugin.
Adapter::format public function Formats a message prior to sending. Overrides MailInterface::format
Adapter::mail public function Sends a message composed by \Drupal\Core\Mail\MailManagerInterface->mail(). Overrides MailInterface::mail
Adapter::__construct public function Constructor.