Final Class Yiisoft\Hydrator\ObjectFactory\ContainerObjectFactory
| Inheritance | Yiisoft\Hydrator\ObjectFactory\ContainerObjectFactory |
|---|---|
| Implements | Yiisoft\Hydrator\ObjectFactory\ObjectFactoryInterface |
A factory for objects that are instantiable by a container.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Hydrator\ObjectFactory\ContainerObjectFactory | |
| create() | Yiisoft\Hydrator\ObjectFactory\ContainerObjectFactory |
Method Details
| public mixed __construct ( \Yiisoft\Injector\Injector $injector ) | ||
| $injector | \Yiisoft\Injector\Injector | |
public function __construct(
private Injector $injector,
) {
}
| public object create ( ReflectionClass $reflectionClass, array $constructorArguments ) | ||
| $reflectionClass | ReflectionClass | |
| $constructorArguments | array | |
| throws | \Psr\Container\ContainerExceptionInterface | |
|---|---|---|
| throws | ReflectionException | |
public function create(ReflectionClass $reflectionClass, array $constructorArguments): object
{
$class = $reflectionClass->getName();
return $this->injector->make($class, $constructorArguments);
}
Signup or Login in order to comment.