You are here

function drush_acsf_variables_acsf_vget_group in Acquia Cloud Site Factory Connector 8

Command callback. Retrieves a group of variables.

File

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

Code

function drush_acsf_variables_acsf_vget_group($group) {
  if (!\Drupal::moduleHandler()
    ->moduleExists('acsf_variables')) {
    return drush_set_error(dt('The acsf_variables module must be enabled.'));
  }
  if (empty($group)) {
    return drush_set_error(dt('You must provide the group name of the variables to retrieve as the first argument.'));
  }
  $format = drush_get_option('format', 'var_export');
  if ($data = \Drupal::service('acsf.variable_storage')
    ->getGroup($group)) {
    if ($format == 'json') {
      $value = drush_format($data, NULL, $format);
    }
    else {
      $value = dt('@group: !value', [
        '@group' => $group,
        '!value' => drush_format($data, NULL, $format),
      ]);
    }
    drush_print($value);
  }
  else {
    return drush_set_error(dt('@group group not found.', [
      '@group' => $group,
    ]));
  }
}