public function AcquiaContentHubSecretCommands::contenthubUpdateSecret in Acquia Content Hub 8.2
Updates the Shared Secret used for Webhook Verification.
@command acquia:contenthub-update-secret @aliases ach-upsec,acquia-contenthub-update-secret
File
- src/
Commands/ AcquiaContentHubSecretCommands.php, line 80
Class
- AcquiaContentHubSecretCommands
- Drush commands for the Content Hub Service secret key.
Namespace
Drupal\acquia_contenthub\CommandsCode
public function contenthubUpdateSecret() {
$client = $this->clientFactory
->getClient();
if (!$client) {
throw new \Exception(dt('The Content Hub client is not connected so the shared secret can not be updated.'));
}
$remote = $client
->getRemoteSettings();
$provider = $this->clientFactory
->getProvider();
if (!empty($remote['shared_secret']) && $provider === 'core_config') {
$config = $this->configFactory
->getEditable('acquia_contenthub.admin_settings');
$config
->set('shared_secret', $remote['shared_secret']);
$config
->save();
$this
->output()
->writeln(dt('The shared secret has been updated to: @secret', [
'@secret' => $remote['shared_secret'],
]));
return;
}
$this
->output()
->writeln(dt('The settings object is read only. Your remote shared secret is: @secret Please update your settings object if necessary.', [
'@secret' => $remote['shared_secret'],
]));
}