public function createService($name, array $args = [])
{
$name = isset($this->meta[self::ALIASES][$name]) ? $this->meta[self::ALIASES][$name] : $name;
$method = self::getMethodName($name);
if (isset($this->creating[$name])) {
throw new Nette\InvalidStateException(sprintf('Circular reference detected for services: %s.', implode(', ', array_keys($this->creating))));
} elseif (!method_exists($this, $method) || (new \ReflectionMethod($this, $method))->getName() !== $method) {
throw new MissingServiceException("Service '{$name}' not found.");
}
try {
$this->creating[$name] = TRUE;
$service = $this->{$method}(...$args);
} finally {
unset($this->creating[$name]);
}
if (!is_object($service)) {
throw new Nette\UnexpectedValueException("Unable to create service '{$name}', value returned by method {$method}() is not object.");
}
return $service;
}