function drush_acquia_contenthub_purge in Acquia Content Hub 8
Purges entities from the Content Hub.
WARNING! This requires elevated keys. This also creates a backup that can be restored later. Be careful when using this command because any subsequent purges overwrite the existing backup. Backups can be restored by using the "restore" command.
Parameters
string|null $api: API Key.
string|null $secret: Secret Key.
Return value
mixed|false Drush Output.
File
- ./
acquia_contenthub.drush.inc, line 501 - ContentHub Drush Commands.
Code
function drush_acquia_contenthub_purge($api = NULL, $secret = NULL) {
/** @var \Drupal\acquia_contenthub\Client\ClientManager $client_manager */
$client_manager = \Drupal::service('acquia_contenthub.client_manager');
$warning_message = "Are you sure you want to PURGE your Content Hub Subscription?\n" . "*************************************************************************************\n" . "PROCEED WITH CAUTION. THIS ACTION WILL PURGE ALL EXISTING ENTITIES IN YOUR CONTENT HUB SUBSCRIPTION.\n" . "While a backup is created for use by the restore command, restoration may not be timely and is not guaranteed. Concurrent or frequent\n" . "use of this command may result in an inability to restore. You can always republish your content as a means of 'recovery'.\n For more information, check https://docs.acquia.com/content-hub.\n" . "*************************************************************************************\n" . "Are you sure you want to proceed?\n";
if (drush_confirm($warning_message)) {
// If API/Secret Keys have been given, reset the connection to use those
// keys instead of the ones set in the configuration.
if (!empty($api) && !empty($secret)) {
$client_manager
->resetConnection([
'api' => $api,
'secret' => $secret,
]);
}
// Execute the 'purge' command.
if ($client_manager
->isConnected()) {
$response = $client_manager
->createRequest('purge');
}
else {
return drush_set_error(dt('Error trying to connect to the Content Hub. Make sure this site is registered to Content hub.'));
}
if (isset($response['success']) && $response['success'] === TRUE) {
// Deleting exported entities from the Tracking Table.
/** @var \Drupal\acquia_contenthub\ContentHubEntitiesTracking $entities_tracking */
$entities_tracking = \Drupal::getContainer()
->get('acquia_contenthub.acquia_contenthub_entities_tracking');
$entities_tracking
->deleteExportedEntities();
drush_print("Your Subscription is being purged. All clients who have registered to received webhooks will be notified with a reindex webhook when the purge process has been completed.\n");
}
else {
return drush_set_error(dt("Error trying to purge your subscription. You might require elevated keys to perform this operation."));
}
}
else {
return drush_user_abort();
}
}