class DrupalMailHandler in Monolog 2.x
Same name and namespace in other branches
- 8 src/Logger/Handler/DrupalMailHandler.php \Drupal\monolog\Logger\Handler\DrupalMailHandler
Class DrupalMailHandler.
Hierarchy
- class \Drupal\monolog\Logger\Handler\DrupalMailHandler extends \Monolog\Handler\MailHandler
Expanded class hierarchy of DrupalMailHandler
File
- src/
Logger/ Handler/ DrupalMailHandler.php, line 12
Namespace
Drupal\monolog\Logger\HandlerView source
class DrupalMailHandler extends MailHandler {
private $to;
/**
* DrupalMailHandler constructor.
*
* @param $to
* @param int $level
* @param bool $bubble
*/
public function __construct($to, $level = Logger::ERROR, $bubble = TRUE) {
parent::__construct($level, $bubble);
$this->to = $to;
}
/**
* {@inheritdoc}
*/
protected function send(string $content, array $records) : void {
/** @var \Drupal\Core\Mail\MailManagerInterface $mail */
$mail = \Drupal::service('plugin.manager.mail');
/** @var \Drupal\Core\Language\LanguageInterface $default_language */
$default_language = \Drupal::languageManager()
->getDefaultLanguage();
$params = [
'content' => Markup::create($content),
'records' => $records,
];
$mail
->mail('monolog', 'default', $this->to, $default_language
->getName(), $params);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalMailHandler:: |
private | property | ||
DrupalMailHandler:: |
protected | function | ||
DrupalMailHandler:: |
public | function | DrupalMailHandler constructor. |