function ServiceContainer::__get in X Autoload 7.4
Same name and namespace in other branches
- 7.5 src/DIC/ServiceContainer.php \Drupal\xautoload\DIC\ServiceContainer::__get()
Magic getter for a service.
Parameters
string $key:
Return value
mixed
Throws
\Exception
Overrides ServiceContainerInterface::__get
File
- lib/
DIC/ ServiceContainer.php, line 56
Class
Namespace
Drupal\xautoload\DICCode
function __get($key) {
if (isset($this->services[$key])) {
return $this->services[$key];
}
if (!method_exists($this->factory, $key)) {
throw new \Exception("Unsupported key '{$key}' for service factory.");
}
return $this->services[$key] = $this->factory
->{$key}($this) ?: FALSE;
}