You are here

class SendGridQueue in SendGrid Integration 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/QueueWorker/SendGridQueue.php \Drupal\sendgrid_integration\Plugin\QueueWorker\SendGridQueue

Sendgrid resend queue worker.

Plugin annotation


@QueueWorker(
  id = "SendGridResendQueue",
  title = @Translation("SendGrid Resend queue"),
  cron = {"time" = 60}
)

Hierarchy

Expanded class hierarchy of SendGridQueue

File

src/Plugin/QueueWorker/SendGridQueue.php, line 19

Namespace

Drupal\sendgrid_integration\Plugin\QueueWorker
View source
class SendGridQueue extends QueueWorkerBase implements ContainerFactoryPluginInterface {

  /**
   * The mail manager service.
   *
   * @var \Drupal\Core\Mail\MailManagerInterface
   */
  protected $mailManager;

  /**
   * SendgridQueue constructor.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin_id for the plugin instance.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   * @param \Drupal\Core\Mail\MailManagerInterface $mailManager
   *   THe mail manager service.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, MailManagerInterface $mailManager) {
    $this->mailManager = $mailManager;
    parent::__construct($configuration, $plugin_id, $plugin_definition);
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('plugin.manager.mail'));
  }

  /**
   * {@inheritdoc}
   */
  public function processItem($message) {

    // Defining parameters first to improve code readability.
    $module = $message['module'];
    $key = $message['key'];
    $to = $message['to'];
    $language = $message['language'];
    $params = $message['params'];
    $from = $message['from'];
    $send = $message['send'];
    $this->mailManager
      ->mail($module, $key, $to, $language, $params, $from, $send);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
SendGridQueue::$mailManager protected property The mail manager service.
SendGridQueue::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
SendGridQueue::processItem public function Works on a single queue item. Overrides QueueWorkerInterface::processItem
SendGridQueue::__construct public function SendgridQueue constructor. Overrides PluginBase::__construct