0 follower

Interface Yiisoft\Definitions\Contract\ReferenceInterface

ExtendsYiisoft\Definitions\Contract\DefinitionInterface
Implemented byYiisoft\Definitions\DynamicReference, Yiisoft\Definitions\Reference

Reference points to another named definition. Usually it is another service in the container or another object definition in the factory.

Public Methods

Hide inherited methods

Method Description Defined By
resolve() Resolve this definition. Yiisoft\Definitions\Contract\DefinitionInterface
to() Create an instance of the reference pointing to ID specified. Yiisoft\Definitions\Contract\ReferenceInterface

Method Details

Hide inherited methods

resolve() public abstract method
public abstract mixed|null resolve ( \Psr\Container\ContainerInterface $container )
$container \Psr\Container\ContainerInterface
return mixed|null

Ready to use object or null if definition can not be resolved and is marked as optional.

throws Yiisoft\Definitions\Exception\InvalidConfigException

If an object of incorrect type was created.

throws Yiisoft\Definitions\Exception\CircularReferenceException

If there is a circular reference detected when resolving the definition.

throws \Psr\Container\NotFoundExceptionInterface

If container does not know how to resolve the definition.

throws Yiisoft\Definitions\Exception\NotInstantiableException

If an object can not be instantiated.

                public function resolve(ContainerInterface $container): mixed;

            
to() public abstract static method

Create an instance of the reference pointing to ID specified.

public abstract static self to ( mixed $id )
$id mixed

ID of the service or object to point to.

throws Yiisoft\Definitions\Exception\InvalidConfigException

When definition configuration is not valid.

                public static function to(mixed $id): self;