public function DrupalStatic::get in X Autoload 7.5
Replicates drupal_static($name, $default_value, FALSE).
Parameters
string $name:
mixed|null $default_value:
Return value
array
See also
File
- tests/
src/ VirtualDrupal/ DrupalStatic.php, line 29
Class
Namespace
Drupal\xautoload\Tests\VirtualDrupalCode
public function &get($name, $default_value = NULL) {
if (!isset($name)) {
throw new \InvalidArgumentException('$name cannot be NULL.');
}
// First check if dealing with a previously defined static variable.
if (isset($this->data[$name]) || array_key_exists($name, $this->data)) {
// Non-NULL $name and both $this->data[$name] and $this->default[$name] statics exist.
return $this->data[$name];
}
// Neither $this->data[$name] nor $this->default[$name] static variables exist.
// First call with new non-NULL $name. Initialize a new static variable.
$this->default[$name] = $this->data[$name] = $default_value;
return $this->data[$name];
}