You are here

class SendMessage in Mass Contact 8

Sends a mass contact message to a given user.

Plugin annotation


@QueueWorker(
  id = "mass_contact_send_message",
  title = @Translation("Sends a mass contact message to an individual recipient")
)

Hierarchy

Expanded class hierarchy of SendMessage

See also

\Drupal\mass_contact\Plugin\QueueWorker\QueueMessages

File

src/Plugin/QueueWorker/SendMessage.php, line 20

Namespace

Drupal\mass_contact\Plugin\QueueWorker
View source
class SendMessage extends QueueWorkerBase implements ContainerFactoryPluginInterface {

  /**
   * The mass contact helper service.
   *
   * @var \Drupal\mass_contact\MassContactInterface
   */
  protected $massContact;

  /**
   * Queue worker constructor.
   *
   * @param array $configuration
   *   The plugin configuration.
   * @param string $plugin_id
   *   The plugin ID.
   * @param mixed $plugin_definition
   *   The plugin definition.
   * @param \Drupal\mass_contact\MassContactInterface $mass_contact
   *   The mass contact helper service.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, MassContactInterface $mass_contact) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->massContact = $mass_contact;
  }

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

  /**
   * {@inheritdoc}
   */
  public function processItem($data) {
    $this->massContact
      ->sendMessage($data['recipients'], $data['message'], $data['configuration']);
  }

}

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.
SendMessage::$massContact protected property The mass contact helper service.
SendMessage::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
SendMessage::processItem public function Works on a single queue item. Overrides QueueWorkerInterface::processItem
SendMessage::__construct public function Queue worker constructor. Overrides PluginBase::__construct