You are here

public function ContentHubSubscription::disconnectClient in Acquia Content Hub 8

Disconnects the client from the Content Hub.

File

src/ContentHubSubscription.php, line 365

Class

ContentHubSubscription
Handles operations on the Acquia Content Hub Subscription.

Namespace

Drupal\acquia_contenthub

Code

public function disconnectClient() {
  $webhook_register = (bool) $this->config
    ->get('webhook_uuid');
  $webhook_url = $this->config
    ->get('webhook_url');

  // Un-register the webhook.
  if ($webhook_register) {
    $this
      ->unregisterWebhook($webhook_url);
  }
  $this->config
    ->delete();

  // Clear the cache for suggested client name after disconnecting the client.
  // @todo Use dependency injection for accessing the cache.
  $cache = \Drupal::cache('acquia_contenthub');
  $cache
    ->delete("suggested_client_name");
  return FALSE;
}