|
| | createConstructorArguments (string $fullyQualifiedClassName, array $parameters, ?callable $with) |
| |
| | getDependency (string $fullyQualifiedClassName, ReflectionParameter $parameter, ?callable $with=null) |
| |
Definition at line 32 of file Injector.php.
◆ __construct()
◆ createConstructorArguments()
| ILIAS\BackgroundTasks\Dependencies\Injector::createConstructorArguments |
( |
string |
$fullyQualifiedClassName, |
|
|
array |
$parameters, |
|
|
?callable |
$with |
|
) |
| |
|
protected |
- Parameters
-
| ReflectionParameter[] | $parameters | |
Definition at line 76 of file Injector.php.
80 : array {
81 $constructorArguments = [];
82
83 foreach ($parameters as $parameter) {
84
85 $constructorArguments[] = $this->
getDependency($fullyQualifiedClassName, $parameter, $with);
86 }
87
88 return $constructorArguments;
89 }
getDependency(string $fullyQualifiedClassName, ReflectionParameter $parameter, ?callable $with=null)
◆ createInstance()
| ILIAS\BackgroundTasks\Dependencies\Injector::createInstance |
( |
string |
$fullyQualifiedClassName, |
|
|
bool |
$requireFile = false, |
|
|
callable |
$with = null |
|
) |
| |
- Parameters
-
| string | $fullyQualifiedClassName | The given class must type hint all its constructor arguments. Furthermore the types must exist in the DI-Container. |
Definition at line 52 of file Injector.php.
56 : object {
57
58 $reflectionClass = new \ReflectionClass($fullyQualifiedClassName);
59 $constructor = $reflectionClass->getConstructor();
60 if ($constructor === null) {
61 return $reflectionClass->newInstance();
62 }
63
64 $parameters = $constructor->getParameters();
65
66
68
69
70 return $reflectionClass->newInstanceArgs($constructorArguments);
71 }
createConstructorArguments(string $fullyQualifiedClassName, array $parameters, ?callable $with)
◆ getDependency()
| ILIAS\BackgroundTasks\Dependencies\Injector::getDependency |
( |
string |
$fullyQualifiedClassName, |
|
|
ReflectionParameter |
$parameter, |
|
|
?callable |
$with = null |
|
) |
| |
|
protected |
- Exceptions
-
Definition at line 94 of file Injector.php.
98 {
99
100
101
102
103
104
105 $type = $parameter->getClass()->getName();
106
107
108
109
110
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.");
113 }
114
115 if ($with) {
116 return $this->dependencyMap->getDependencyWith($this->dic,
$type, $fullyQualifiedClassName, $with);
117 } else {
118 return $this->dependencyMap->getDependency($this->dic,
$type, $fullyQualifiedClassName);
119 }
120 }
References $type.
◆ $dependencyMap
◆ $dic
The documentation for this class was generated from the following file: