0 follower

Final Class Yiisoft\Definitions\DynamicReference

InheritanceYiisoft\Definitions\DynamicReference
ImplementsYiisoft\Definitions\Contract\ReferenceInterface

The DynamicReference defines a dependency to a service not defined in the container.

Definition may be defined multiple ways ({@see \Yiisoft\Definitions\Helpers\Normalizer}). For example:

[
   MyService::class => [
       '__construct()' => [
           DynamicReference::to([
               'class' => SomeClass::class,
               '$someProp' => 15
           ])
       ]
   ]
]

Method Details

Hide inherited methods

resolve() public method

public mixed resolve ( \Psr\Container\ContainerInterface $container )
$container \Psr\Container\ContainerInterface

                public function resolve(ContainerInterface $container): mixed
{
    return $this->definition->resolve($container);
}

            
to() public static method
public static self to ( mixed $id )
$id mixed
throws Yiisoft\Definitions\Exception\InvalidConfigException

If definition is not valid.

                public static function to(mixed $id): self
{
    return new self($id);
}