protected function AcquiaContentHubPurgeCommands::resetConnection in Acquia Content Hub 8.2
Resets a connection to the client to use a new api and secret key.
Parameters
\Acquia\ContentHubClient\ContentHubClient $client: Client.
string $api_key: API key.
string $secret_key: Secret key.
Return value
\Acquia\ContentHubClient\ContentHubClient New client instance.
2 calls to AcquiaContentHubPurgeCommands::resetConnection()
- AcquiaContentHubPurgeCommands::contenthubPurge in src/
Commands/ AcquiaContentHubPurgeCommands.php - Purges all entities from Acquia Content Hub.
- AcquiaContentHubPurgeCommands::contenthubRestore in src/
Commands/ AcquiaContentHubPurgeCommands.php - Restores the backup taken by a previous execution of the "purge" command.
File
- src/
Commands/ AcquiaContentHubPurgeCommands.php, line 198
Class
- AcquiaContentHubPurgeCommands
- Drush commands for purging Acquia Content Hub.
Namespace
Drupal\acquia_contenthub\CommandsCode
protected function resetConnection(ContentHubClient $client, $api_key, $secret_key) {
$settings = $client
->getSettings();
$new_settings = new Settings($settings
->getName(), $settings
->getUuid(), $api_key, $secret_key, $settings
->getUrl());
// Find out the module version in use.
$module_info = $this->moduleList
->getExtensionInfo('acquia_contenthub');
$module_version = isset($module_info['version']) ? $module_info['version'] : '0.0.0';
$drupal_version = isset($module_info['core']) ? $module_info['core'] : '0.0.0';
$client_user_agent = 'AcquiaContentHub/' . $drupal_version . '-' . $module_version;
// Override configuration.
$config = [
'base_url' => $settings
->getUrl(),
'client-user-agent' => $client_user_agent,
];
$dispatcher = \Drupal::service('event_dispatcher');
return new ContentHubClient($config, $this
->logger(), $new_settings, $new_settings
->getMiddleware(), $dispatcher);
}