You are here

class MessageWorker in Courier 8

Same name and namespace in other branches
  1. 2.x src/Plugin/QueueWorker/MessageWorker.php \Drupal\courier\Plugin\QueueWorker\MessageWorker

Triggers scheduled rules.

Plugin annotation


@QueueWorker(
  id = "courier_message",
  title = @Translation("Courier message processor"),
  cron = {"time" = 30}
)

Hierarchy

Expanded class hierarchy of MessageWorker

File

src/Plugin/QueueWorker/MessageWorker.php, line 22
Contains \Drupal\courier\Plugin\QueueWorker\MessageWorker.

Namespace

Drupal\courier\Plugin\QueueWorker
View source
class MessageWorker extends QueueWorkerBase {

  /**
   * {@inheritdoc}
   *
   * @param $data
   *   - integer $id: ID of a courier_message_queue_item entity.
   */
  public function processItem($data) {
    $message_queue = MessageQueueItem::load($data['id']);
    if ($message_queue) {

      /** @var \Drupal\courier\Service\MessageQueueManagerInterface $service */
      $service = \Drupal::service('courier.manager.message_queue');
      $service
        ->sendMessage($message_queue);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MessageWorker::processItem public function Overrides QueueWorkerInterface::processItem
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.
PluginBase::__construct public function Constructs a \Drupal\Component\Plugin\PluginBase object. 92