public function ContentHubSubscription::unregisterWebhook in Acquia Content Hub 8
Unregisters a Webhook from Content Hub.
Parameters
string $webhook_url: The webhook URL.
Return value
bool TRUE if successful unregistration, FALSE otherwise.
1 call to ContentHubSubscription::unregisterWebhook()
- ContentHubSubscription::disconnectClient in src/
ContentHubSubscription.php - Disconnects the client from the Content Hub.
File
- src/
ContentHubSubscription.php, line 334
Class
- ContentHubSubscription
- Handles operations on the Acquia Content Hub Subscription.
Namespace
Drupal\acquia_contenthubCode
public function unregisterWebhook($webhook_url) {
if ($settings = $this->clientManager
->createRequest('getSettings')) {
if ($webhook = $settings
->getWebhook($webhook_url)) {
if ($response = $this->clientManager
->createRequest('deleteWebhook', [
$webhook['uuid'],
$webhook['url'],
])) {
$success = json_decode($response
->getBody(), TRUE);
if (isset($success['success']) && $success['success'] == TRUE) {
\Drupal::messenger()
->addWarning($this
->t('Webhooks have been <b>disabled</b>. This site will no longer receive updates from Content Hub.', [
'@URL' => $webhook['url'],
]));
$this->config
->clear('webhook_uuid')
->clear('webhook_url')
->save();
return TRUE;
}
}
}
else {
// If the webhook was not found in the Subscription settings but the
// variables are still set, we should delete the variables to be in
// sync with the subscription settings.
$this->config
->clear('webhook_uuid')
->clear('webhook_url')
->save();
return TRUE;
}
}
return FALSE;
}