You are here

public function AcsfVariablesCommands::vgetGroup in Acquia Cloud Site Factory Connector 8.2

Retrieves a group of variables.

@command acsf-vget-group

Parameters

string $group: The group name of the variable to retrieve.

Return value

\Consolidation\OutputFormatters\StructuredData\PropertyList PropertyList of the variables.

Throws

\Drupal\acsf\AcsfException If the variable does not exist with the provided name or the acsf_variables module isn't enabled.

\InvalidArgumentException If the argument is missing or invalid.

File

acsf_variables/src/Commands/AcsfVariablesCommands.php, line 118

Class

AcsfVariablesCommands
Provides drush commands for the acsf_variables module.

Namespace

Drupal\acsf_variables\Commands

Code

public function vgetGroup($group) {
  if (!\Drupal::moduleHandler()
    ->moduleExists('acsf_variables')) {
    throw new AcsfException(dt('The acsf_variables module must be enabled.'));
  }
  if (empty($group)) {
    throw new \InvalidArgumentException(dt('You must provide the group name of the variables to retrieve as the first argument.'));
  }
  if ($data = \Drupal::service('acsf.variable_storage')
    ->getGroup($group)) {
    return new PropertyList($data);
  }
  else {
    throw new AcsfException(dt('@group group not found.', [
      '@group' => $group,
    ]));
  }
}