\Drupal\strata\Event\Webhook WebhookSubscription

One endpoint, the events it wants, and the secret its payloads are signed with.

A value object read out of configuration rather than a config entity, because a subscription has no identity beyond its URL and nothing else in the site refers to one. A list in a config object exports and imports with the rest of the configuration and needs no entity type, no list builder and no access handler.

An empty event list means every event. That is the shape an operator reaches for first, and making them tick six boxes to get it would only teach them to ignore the boxes.

Summary

Methods
Properties
Constants
__construct
wants
isSigned
label
jsonSerialize
fromArray
fromSequence
url
secret
events
enabled
timeout
attempts
DEFAULT_TIMEOUT
DEFAULT_ATTEMPTS
No protected methods found
No protected properties found
No protected constants found
No private methods found
No private properties found
No private constants found

Constant

DEFAULT_TIMEOUT

DEFAULT_TIMEOUT = 10

Seconds to wait for an endpoint before giving up on one attempt.

DEFAULT_ATTEMPTS

DEFAULT_ATTEMPTS = 3

Attempts one delivery gets, including the first.

Properties

$url

$url : string

Type

string

$secret

$secret : string

Type

string

$events

$events : array

Type

array<string|int, mixed>

$enabled

$enabled : bool

Type

bool

$timeout

$timeout : int

Type

int

$attempts

$attempts : int

Type

int

Methods

__construct()

__construct(string  $url, string  $secret = '', list  $events = [], bool  $enabled = true, int  $timeout = \self::DEFAULT_TIMEOUT, int  $attempts = \self::DEFAULT_ATTEMPTS) : mixed

Constructs a subscription.

Parameters

string $url

Where the payload is posted.

string $secret

The signing secret, or an empty string to send unsigned.

list $events

Event names this endpoint wants, or an empty list for every event.

bool $enabled

Whether deliveries are attempted at all.

int $timeout

Seconds one attempt may take.

int $attempts

Attempts before the delivery is abandoned.

Returns

mixed —

wants()

wants(string  $event) : bool

Whether this subscription wants a given event.

Parameters

string $event

The event name.

Returns

bool —

TRUE when the subscription is enabled and either lists the event or lists none.

isSigned()

isSigned() : bool

Whether payloads to this endpoint are signed.

Returns

bool —

TRUE when a secret is set.

label()

label() : string

A label for an operator-facing list.

Returns

string —

The host, and what it is subscribed to.

jsonSerialize()

jsonSerialize() : array

{@inheritdoc}

Returns

array —

fromArray()

fromArray(array  $values) : self

Reads a subscription out of configuration.

Unknown event names are dropped rather than kept, so a subscription written against a later release does not silently receive nothing on this one; what it does receive is what this release can actually send. An empty result after filtering is the every-event shape, which is the safe direction: an operator sees too much rather than nothing.

Parameters

array $values

One entry of the subscriptions sequence.

Returns

self —

The subscription.

fromSequence()

fromSequence(list>|null  $sequence) : list<self>

Reads every subscription out of a configuration sequence.

Parameters

list>|null $sequence

The subscriptions value, or NULL when none is configured.

Returns

list

The subscriptions that name a URL.