You are here

protected function WebhookConfigForm::eventOptions in Webhooks 8

Generate a list of available events.

Return value

array Array of string identifiers for outgoing event options.

1 call to WebhookConfigForm::eventOptions()
WebhookConfigForm::form in src/Form/WebhookConfigForm.php
Gets the actual form array to be built.

File

src/Form/WebhookConfigForm.php, line 325

Class

WebhookConfigForm
Class Webhook Config Form.

Namespace

Drupal\webhooks\Form

Code

protected function eventOptions() {
  $entity_types = $this->entityTypeManager
    ->getDefinitions();
  $options = [];
  foreach ($entity_types as $entity_type => $definition) {
    if ($definition
      ->entityClassImplements('\\Drupal\\Core\\Entity\\ContentEntityInterface')) {
      foreach ($this->entityHooks as $hook) {
        $options['entity:' . $entity_type . ':' . $hook] = [
          'type' => $this
            ->t('Hook: %entity_label', [
            '%entity_label' => ucfirst($definition
              ->getLabel()),
          ]),
          'event' => 'entity:' . $entity_type . ':' . $hook,
        ];
      }
    }
  }
  foreach ($this->systemHooks as $hook) {
    $options['system:' . $hook] = [
      'type' => $this
        ->t('Hook: %hook', [
        '%hook' => ucfirst($hook),
      ]),
      'event' => 'system:' . $hook,
    ];
  }
  $this->moduleHandler
    ->alter('webhooks_event_info', $options);
  return $options;
}