You are here

function DrupalComponentContainer::__get in X Autoload 7.5

Magic getter for a Drupal component.

Parameters

string $key:

Return value

object

Throws

\Exception

File

tests/src/VirtualDrupal/DrupalComponentContainer.php, line 57

Class

DrupalComponentContainer
@property ModuleEnable ModuleEnable @property DrupalGetFilename DrupalGetFilename @property SystemUpdateBootstrapStatus SystemUpdateBootstrapStatus @property SystemRebuildModuleData SystemRebuildModuleData @property SystemListReset…

Namespace

Drupal\xautoload\Tests\VirtualDrupal

Code

function __get($key) {
  if (array_key_exists($key, $this->components)) {
    return $this->components[$key];
  }
  $method = 'get' . $key;
  if (!method_exists($this, $method)) {
    throw new \Exception("Unsupported key '{$key}' for DrupalComponentContainer.");
  }
  return $this->components[$key] = $this
    ->{$method}($this);
}