You are here

function drush_acsf_variables_acsf_vdel in Acquia Cloud Site Factory Connector 8

Command callback. Deletes a named variable.

File

acsf_variables/acsf_variables.drush.inc, line 160
Provides drush commands for the acsf_variables module.

Code

function drush_acsf_variables_acsf_vdel($name) {
  if (!\Drupal::moduleHandler()
    ->moduleExists('acsf_variables')) {
    return drush_set_error(dt('The acsf_variables module must be enabled.'));
  }
  if (empty($name)) {
    return drush_set_error(dt('You must provide the name of the variable to delete as the first argument.'));
  }
  $storage = \Drupal::service('acsf.variable_storage');
  if ($variable = $storage
    ->get($name)) {
    if ($storage
      ->delete($name)) {
      drush_print(dt('@name was deleted.', [
        '@name' => $name,
      ]));
    }
    else {
      return drush_set_error(dt('Unable to delete the @name variable.', [
        '@name' => $name,
      ]));
    }
  }
  else {
    return drush_set_error(dt('@name not found.', [
      '@name' => $name,
    ]));
  }
}