You are here

public function AcquiaContentHubSecretCommands::contenthubRegenerateSecret in Acquia Content Hub 8.2

Regenerates the Shared Secret used for Webhook Verification.

@command acquia:contenthub-regenerate-secret @aliases ach-regsec,acquia-contenthub-regenerate-secret

Throws

\Exception

File

src/Commands/AcquiaContentHubSecretCommands.php, line 51

Class

AcquiaContentHubSecretCommands
Drush commands for the Content Hub Service secret key.

Namespace

Drupal\acquia_contenthub\Commands

Code

public function contenthubRegenerateSecret() {
  $client = $this->clientFactory
    ->getClient();
  $warning_message = "Are you sure you want to REGENERATE your shared-secret in the Content Hub?\n" . "*************************************************************************************\n" . "PROCEED WITH CAUTION. THIS COULD POTENTIALLY LEAD TO HAVING SOME SITES OUT OF SYNC.\n" . "Make sure you have ALL your sites correctly configured to receive webhooks before attempting to do this.\n" . "For more information, check https://docs.acquia.com/content-hub/known-issues.\n" . "*************************************************************************************\n";
  if ($this
    ->io()
    ->confirm($warning_message)) {
    if (!$client) {
      throw new \Exception(dt('Error trying to connect to the Content Hub. Make sure this site is registered to Content hub.'));
    }
    $output = $client
      ->regenerateSharedSecret();
    if ($output) {
      $this
        ->output()
        ->writeln("Your Shared Secret has been regenerated. All clients who have registered to received webhooks are being notified of this change.\n");
    }
    else {
      throw new \Exception(dt("Error trying to regenerate the shared-secret in your subscription. Try again later."));
    }
  }
}