You are here

class WebhookDispatcher in Webhooks 8

A Webhook dispatcher that dispatches webhooks on CRON run.

Plugin annotation


@QueueWorker(
  id = "webhooks_dispatcher",
  title = @Translation("Webhooks Dispatcher"),
  cron = {"time" = 60}
)

Hierarchy

Expanded class hierarchy of WebhookDispatcher

File

src/Plugin/QueueWorker/WebhookDispatcher.php, line 22

Namespace

Drupal\webhooks\Plugin\QueueWorker
View source
class WebhookDispatcher extends QueueWorkerBase implements ContainerFactoryPluginInterface {

  /**
   * The event dispatcher.
   *
   * @var \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher
   */
  protected $eventDispatcher;

  /**
   * WebhookDispatcherBase constructor.
   *
   * @param \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher $event_dispatcher
   *   The event dispathcer.
   */
  public function __construct(ContainerAwareEventDispatcher $event_dispatcher) {
    $this->eventDispatcher = $event_dispatcher;
  }

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

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

    /** @var \Drupal\webhooks\Entity\WebhookConfig $webhook_config */
    $webhook_config = WebhookConfig::load($data['id']);
    if ($webhook_config) {
      $this->eventDispatcher
        ->dispatch(WebhookEvents::RECEIVE, new ReceiveEvent($webhook_config, $data['webhook']));
    }
  }

}

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.
WebhookDispatcher::$eventDispatcher protected property The event dispatcher.
WebhookDispatcher::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
WebhookDispatcher::processItem public function Works on a single queue item. Overrides QueueWorkerInterface::processItem
WebhookDispatcher::__construct public function WebhookDispatcherBase constructor. Overrides PluginBase::__construct