You are here

public function WebhooksService::triggerEvent in Webhooks 8

Trigger all webhook subscriptions associated with the given event.

Parameters

\Drupal\webhooks\Webhook $webhook: The webhook object.

string $event: Identifier of a particular webhook event, e.g. entity:node:create, entity:user:update or entity:taxonomy_term:delete.

Overrides WebhookDispatcherInterface::triggerEvent

File

src/WebhooksService.php, line 157

Class

WebhooksService
Class WebhookService.

Namespace

Drupal\webhooks

Code

public function triggerEvent(Webhook $webhook, $event) {

  // Load all webhooks for the occurring event.

  /** @var \Drupal\webhooks\Entity\WebhookConfig $webhook_config */
  $webhook_configs = $this
    ->loadMultipleByEvent($event);
  foreach ($webhook_configs as $webhook_config) {

    // Send the Webhook object.
    $this
      ->send($webhook_config, $webhook);
  }
}