\Drupal\strata\Form WebhookSettingsForm

The endpoints that are told when something happens.

A secret already stored is never rendered back into the form. A configuration form that showed the current value would put every subscription's signing secret into the HTML of a page, into the browser's cache and into any proxy in between. So the field is left blank with a note that it is set, and an empty submission keeps what is there rather than clearing it - which means clearing a secret deliberately needs its own control.

The event list comes from StrataEvents::all(), so an event added in a later release appears here without this form being edited.

Summary

Methods
Properties
Constants
getFormId
buildForm
submitForm
No public properties found
SLOTS
getEditableConfigNames
No protected properties found
No protected constants found
secretFor
chosenEvents
eventOptions
slot
at
subscriptions
No private properties found
No private constants found

Constant

SLOTS

SLOTS = 5

Subscriptions the form renders.

Fixed rather than unlimited, because a site needing more than this is integrating through something other than a settings form.

Methods

getFormId()

getFormId() : string

{@inheritdoc}

Returns

string —

buildForm()

buildForm(array  $form, \Drupal\Core\Form\FormStateInterface  $form_state) : array

{@inheritdoc}

Parameters

array $form
\Drupal\Core\Form\FormStateInterface $form_state

Returns

array —

submitForm()

submitForm(array  $form, \Drupal\Core\Form\FormStateInterface  $form_state) : void

{@inheritdoc}

Parameters

array $form
\Drupal\Core\Form\FormStateInterface $form_state

Returns

void —

getEditableConfigNames()

getEditableConfigNames() : list<string>

{@inheritdoc}

Returns

list

The configuration this form edits.

secretFor()

secretFor(array  $values, \Drupal\strata\Event\Webhook\WebhookSubscription|null  $existing) : string

The secret to store for one slot.

Parameters

array $values

The submitted slot.

\Drupal\strata\Event\Webhook\WebhookSubscription|null $existing

What was stored before, or NULL for a new endpoint.

Returns

string —

The secret to store, which may be what was already there.

chosenEvents()

chosenEvents(array  $values) : list<string>

The events one slot ticked.

Parameters

array $values

The submitted slot.

Returns

list

Event names, empty for every event.

eventOptions()

eventOptions() : array<string,string>

Every event, labelled.

Returns

array

Event name keyed to a label.

slot()

slot(int  $slot) : string

The form element name for one slot.

Parameters

int $slot

The slot index.

Returns

string —

The element name.

at()

at(list<\Drupal\strata\Event\Webhook\WebhookSubscription>  $existing, int  $slot) : \Drupal\strata\Event\Webhook\WebhookSubscription|null

The subscription filling one slot, if there is one.

A slot past the end of the stored list is empty, which is the normal case: the form always renders every slot and a site usually configures fewer.

Parameters

list<\Drupal\strata\Event\Webhook\WebhookSubscription> $existing

What is stored.

int $slot

The slot index.

Returns

\Drupal\strata\Event\Webhook\WebhookSubscription|null —

The subscription, or NULL when the slot is empty.

subscriptions()

subscriptions() : list<\Drupal\strata\Event\Webhook\WebhookSubscription>

The subscriptions currently stored.

Returns

list<\Drupal\strata\Event\Webhook\WebhookSubscription> —

The subscriptions.