class SendMailBase in Mailgun 8
Provides base functionality for the SendMail Queue Workers.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
- class \Drupal\mailgun\Plugin\QueueWorker\SendMailBase implements ContainerFactoryPluginInterface
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
Expanded class hierarchy of SendMailBase
File
- src/
Plugin/ QueueWorker/ SendMailBase.php, line 15
Namespace
Drupal\mailgun\Plugin\QueueWorkerView source
class SendMailBase extends QueueWorkerBase implements ContainerFactoryPluginInterface {
/**
* Mailgun config.
*
* @var \Drupal\Core\Config\ImmutableConfig
*/
protected $mailgunConfig;
/**
* Mailgun Logger instance.
*
* @var \Psr\Log\LoggerInterface
*/
protected $logger;
/**
* Mailgun mail handler.
*
* @var \Drupal\mailgun\MailgunHandlerInterface
*/
protected $mailgunHandler;
/**
* SendMailBase constructor.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, ImmutableConfig $settings, LoggerInterface $logger, MailgunHandlerInterface $mailgun_handler) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->mailgunConfig = $settings;
$this->logger = $logger;
$this->mailgunHandler = $mailgun_handler;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('config.factory')
->get(MailgunHandlerInterface::CONFIG_NAME), $container
->get('logger.factory')
->get('mailgun'), $container
->get('mailgun.mail_handler'));
}
/**
* {@inheritdoc}
*/
public function processItem($data) {
$result = $this->mailgunHandler
->sendMail($data->message);
if ($this->mailgunConfig
->get('debug_mode')) {
$this->logger
->notice('Successfully sent message on CRON from %from to %to.', [
'%from' => $data->message['from'],
'%to' => $data->message['to'],
]);
}
if (!$result) {
throw new \Exception('Mailgun: email did not pass through API.');
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
SendMailBase:: |
protected | property | Mailgun Logger instance. | |
SendMailBase:: |
protected | property | Mailgun config. | |
SendMailBase:: |
protected | property | Mailgun mail handler. | |
SendMailBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
SendMailBase:: |
public | function |
Works on a single queue item. Overrides QueueWorkerInterface:: |
|
SendMailBase:: |
public | function |
SendMailBase constructor. Overrides PluginBase:: |