public function ContentHubConnectionManager::unregisterWebhook in Acquia Content Hub 8.2
Unregisters the webhook url assigned to this site.
Parameters
\Drupal\acquia_contenthub\Event\AcquiaContentHubUnregisterEvent $event: AcquiaContentHubUnregisterEvent instance.
bool $delete_orphaned_filters: TRUE if orphaned filters should be deleted, FALSE otherwise.
Return value
bool TRUE, if un-registration is successful, FALSE otherwise.
1 call to ContentHubConnectionManager::unregisterWebhook()
- ContentHubConnectionManager::unregister in src/
ContentHubConnectionManager.php - Unregisters the client.
File
- src/
ContentHubConnectionManager.php, line 308
Class
- ContentHubConnectionManager
- Responsible for connection management actions.
Namespace
Drupal\acquia_contenthubCode
public function unregisterWebhook(AcquiaContentHubUnregisterEvent $event, bool $delete_orphaned_filters = FALSE) : bool {
$this
->initialize();
$resp = $this->client
->deleteWebhook($event
->getWebhookUuid());
if ($resp instanceof ResponseInterface && $resp
->getStatusCode() !== Response::HTTP_OK) {
$this->logger
->error('Could not unregister webhook: @e_message', [
'@e_message' => $resp
->getReasonPhrase(),
]);
return FALSE;
}
// Clears the webhook configuration.
$this
->getContentHubConfig()
->clear('webhook')
->save();
$resp = $this->client
->deleteFilter($event
->getDefaultFilter());
if ($resp instanceof ResponseInterface && $resp
->getStatusCode() !== Response::HTTP_OK) {
$this->logger
->error('Could not delete default filter for webhook: @e_message', [
'@e_message' => $resp
->getReasonPhrase(),
]);
return FALSE;
}
if ($delete_orphaned_filters) {
foreach ($event
->getOrphanedFilters() as $filter_id) {
if ($this->client
->deleteFilter($filter_id) instanceof ResponseInterface && $resp
->getStatusCode() !== Response::HTTP_OK) {
$this->logger
->error('
Could not delete orphaned filter (@filter) for webhook: @e_message', [
'@e_message' => $resp
->getReasonPhrase(),
'@filter' => $filter_id,
]);
return FALSE;
}
}
}
return TRUE;
}