You are here

function drush_acsf_variables_acsf_vset in Acquia Cloud Site Factory Connector 8

Command callback. Sets a named variable with an optional group.

File

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

Code

function drush_acsf_variables_acsf_vset($name, $value) {
  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 set as the first argument.'));
  }
  if (empty($value)) {
    return drush_set_error(dt('You must provide the value of the variable to set as the second argument.'));
  }
  if (\Drupal::service('acsf.variable_storage')
    ->set($name, $value, drush_get_option('group'))) {
    drush_print(dt('@name was set to !value', [
      '@name' => $name,
      '!value' => $value,
    ]));
  }
  else {
    return drush_set_error(dt('The @name variable could not be set.'));
  }
}