You are here

public function AcsfVariableStorage::get in Acquia Cloud Site Factory Connector 8.2

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

Retrieves a named variable.

Parameters

string $name: The name of the variable.

mixed $default: The default value of the variable.

Return value

mixed The value of the variable.

File

src/AcsfVariableStorage.php, line 64

Class

AcsfVariableStorage
Encapsulates functionality to interact with ACSF variables.

Namespace

Drupal\acsf

Code

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