Definition at line 19 of file Injector.php.
◆ __construct()
◆ createConstructorArguments()
ILIAS\BackgroundTasks\Dependencies\Injector::createConstructorArguments |
( |
|
$fullyQualifiedClassName, |
|
|
|
$parameters, |
|
|
|
$with |
|
) |
| |
|
protected |
◆ createInstance()
ILIAS\BackgroundTasks\Dependencies\Injector::createInstance |
( |
|
$fullyQualifiedClassName, |
|
|
|
$requireFile = false , |
|
|
callable |
$with = null |
|
) |
| |
- Parameters
-
| $fullyQualifiedClassName | string The given class must type hint all its constructor arguments. Furthermore the types must exist in the DI-Container. |
bool | $requireFile | |
- Returns
- object
@noinspection PhpIncludeInspection
Definition at line 54 of file Injector.php.
55 {
56 if ($requireFile) {
57 require_once($requireFile);
58 }
59
60
61 $reflectionClass = new \ReflectionClass($fullyQualifiedClassName);
62 $constructor = $reflectionClass->getConstructor();
63 if (!$constructor) {
64 return $reflectionClass->newInstance();
65 }
66
67 $parameters = $constructor->getParameters();
68
69
71
72
73 return $reflectionClass->newInstanceArgs($constructorArguments);
74 }
createConstructorArguments($fullyQualifiedClassName, $parameters, $with)
References ILIAS\BackgroundTasks\Dependencies\Injector\createConstructorArguments().
◆ getDependency()
ILIAS\BackgroundTasks\Dependencies\Injector::getDependency |
( |
|
$fullyQualifiedClassName, |
|
|
|
$parameter, |
|
|
callable |
$with = null |
|
) |
| |
|
protected |
- Parameters
-
| $fullyQualifiedClassName | string |
| $parameter | ReflectionParameter |
callable | $with | |
- Returns
- mixed
- Exceptions
-
Definition at line 106 of file Injector.php.
107 {
108
109
110
111
112
113
114 $type = $parameter->getClass()->getName();
115
116
117
118
119
121 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.");
122 }
123
124 if ($with) {
125 return $this->dependencyMap->getDependencyWith($this->dic,
$type, $fullyQualifiedClassName, $with);
126 } else {
127 return $this->dependencyMap->getDependency($this->dic,
$type, $fullyQualifiedClassName);
128 }
129 }
References $type.
Referenced by ILIAS\BackgroundTasks\Dependencies\Injector\createConstructorArguments().
◆ $dependencyMap
ILIAS\BackgroundTasks\Dependencies\Injector::$dependencyMap |
|
protected |
◆ $dic
ILIAS\BackgroundTasks\Dependencies\Injector::$dic |
|
protected |
The documentation for this class was generated from the following file: