You are here

function mailchimp_lists_enabled_webhook_events in Mailchimp 8

Same name and namespace in other branches
  1. 2.x modules/mailchimp_lists/mailchimp_lists.module \mailchimp_lists_enabled_webhook_events()

Returns an array of enabled webhook events.

Parameters

string $list_id: The Mailchimp list/audience ID to return webhook actions for.

Return value

array An array of enabled webhook event names.

2 calls to mailchimp_lists_enabled_webhook_events()
MailchimpListsController::overview in modules/mailchimp_lists/src/Controller/MailchimpListsController.php
MailchimpListsWebhookSettingsForm::buildForm in modules/mailchimp_lists/src/Form/MailchimpListsWebhookSettingsForm.php
Form constructor.

File

modules/mailchimp_lists/mailchimp_lists.module, line 575
Mailchimp lists/audiences module.

Code

function mailchimp_lists_enabled_webhook_events($list_id) {
  $enabled_events = [];
  $webhook_url = mailchimp_webhook_url();
  $webhooks = mailchimp_webhook_get($list_id);
  if ($webhooks) {
    foreach ($webhooks as $webhook) {
      if ($webhook_url == $webhook->url) {
        foreach ($webhook->events as $event => $enabled) {
          if ($enabled) {
            $enabled_events[] = $event;
          }
        }
      }
    }
  }
  return $enabled_events;
}