You are here

function drush_acquia_contenthub_delete in Acquia Content Hub 8

Deletes single entities from the Content Hub.

Parameters

string $uuid: Uuid of entity to delete.

Return value

mixed|false TRUE if entity is deleted, FALSE otherwise.

File

./acquia_contenthub.drush.inc, line 456
ContentHub Drush Commands.

Code

function drush_acquia_contenthub_delete($uuid = NULL) {

  /** @var \Drupal\acquia_contenthub\Client\ClientManager $client_manager */
  $client_manager = \Drupal::service('acquia_contenthub.client_manager');
  if (!Uuid::isValid($uuid)) {
    return drush_set_error(dt("Argument provided is not a UUID."));
  }
  else {
    if (drush_confirm(dt('Are you sure you want to delete the entity with uuid = @uuid from the Content Hub? There is no way back from this action!', [
      '@uuid' => $uuid,
    ]))) {
      $client = $client_manager
        ->getConnection();
      if ($client
        ->deleteEntity($uuid)) {
        drush_print(dt("Entity with UUID = @uuid has been successfully deleted from the Content Hub.", [
          '@uuid' => $uuid,
        ]));
      }
      else {
        return drush_set_error(dt("Entity with UUID = @uuid cannot be deleted.", [
          '@uuid' => $uuid,
        ]));
      }
    }
    else {
      return drush_user_abort();
    }
  }
}