34 protected \ILIAS\DI\Container
$dic;
35 protected \ILIAS\BackgroundTasks\Dependencies\DependencyMap\DependencyMap
$dependencyMap;
53 string $fullyQualifiedClassName,
54 bool $requireFile =
false,
58 $reflectionClass = new \ReflectionClass($fullyQualifiedClassName);
59 $constructor = $reflectionClass->getConstructor();
60 if ($constructor === null) {
61 return $reflectionClass->newInstance();
64 $parameters = $constructor->getParameters();
70 return $reflectionClass->newInstanceArgs($constructorArguments);
77 string $fullyQualifiedClassName,
81 $constructorArguments = [];
83 foreach ($parameters as $parameter) {
85 $constructorArguments[] = $this->
getDependency($fullyQualifiedClassName, $parameter, $with);
88 return $constructorArguments;
95 string $fullyQualifiedClassName,
97 ?callable $with = null
105 $type = $parameter->getClass()->getName();
112 throw new InvalidClassException(
"The DI cannot instantiate $fullyQualifiedClassName because some of the constructors arguments are not type hinted. Make sure all parameters in the constructor have type hinting.");
116 return $this->dependencyMap->getDependencyWith($this->dic,
$type, $fullyQualifiedClassName, $with);
118 return $this->dependencyMap->getDependency($this->dic,
$type, $fullyQualifiedClassName);
Customizing of pimple-DIC for ILIAS.
createConstructorArguments(string $fullyQualifiedClassName, array $parameters, ?callable $with)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS BackgroundTasks Dependencies DependencyMap DependencyMap $dependencyMap
__construct(Container $dic, DependencyMap $dependencyMap)
Factory constructor.
createInstance(string $fullyQualifiedClassName, bool $requireFile=false, callable $with=null)
getDependency(string $fullyQualifiedClassName, ReflectionParameter $parameter, ?callable $with=null)