You are here

public function AcsfVariableStorage::getGroup in Acquia Cloud Site Factory Connector 8

Same name and namespace in other branches
  1. 8.2 src/AcsfVariableStorage.php \Drupal\acsf\AcsfVariableStorage::getGroup()

Retrieves a group of variables.

Parameters

string $group: The group name of the variables.

mixed $default: The default value of the group.

Return value

array An associative array holding the values of the group of variables, keyed by the variable names.

File

src/AcsfVariableStorage.php, line 117

Class

AcsfVariableStorage
Encapsulates functionality to interact with ACSF variables.

Namespace

Drupal\acsf

Code

public function getGroup($group, $default = []) {
  $return = [];
  $result = $this->connection
    ->select('acsf_variables', 'v')
    ->fields('v', [
    'name',
    'value',
  ])
    ->condition('group_name', $group, '=')
    ->execute();
  while ($record = $result
    ->fetchAssoc()) {
    $return[$record['name']] = unserialize($record['value']);
  }
  if (empty($return)) {
    return $default;
  }
  else {
    return $return;
  }
}