BaseResolver extends AbstractResolver
in package

Base Resolver

Handles singleton vs non-singleton resolution of services.

Tags
since
4.0.0

Table of Contents

Properties

$singleton  : bool
Whether this resolver should return a singleton instance.
$resolved_value  : mixed
Cached resolved value (for singletons).

Methods

__construct()  : mixed
Constructor.
get()  : mixed
Get the resolved value.
resolve()  : mixed
Resolve the callback to a value.

Properties

Methods

__construct()

Constructor.

public __construct(mixed $value, bool $singleton) : mixed
Parameters
$value : mixed

Either a closure or the value itself.

$singleton : bool

Whether to cache the resolved value.

get()

Get the resolved value.

public get(Container $container) : mixed

If singleton is true, the value is cached and returned on subsequent calls. Otherwise, a new instance is created each time.

Parameters
$container : Container

The container instance.

Return values
mixed

The resolved value.

resolve()

Resolve the callback to a value.

protected resolve(Container $container) : mixed

If the callback is callable, it will be invoked with the container as an argument. Otherwise, the callback itself is returned.

If the resolved value is an object with an initialize() method, it will be called automatically. This allows services to set up hooks and filters upon instantiation.

Parameters
$container : Container

The container instance.

Return values
mixed

The resolved value.


        
On this page

Search results