AbstractResolver
in package
AbstractYes
Abstract Resolver
Base class for service resolvers. Handles the callback storage and resolution logic.
Tags
Table of Contents
Properties
- $singleton : bool
- Whether this resolver should return a singleton instance.
- $callback : mixed
- The callback or value to resolve.
Methods
- __construct() : mixed
- Constructor.
- get() : mixed
- Get the resolved value.
- resolve() : mixed
- Resolve the callback to a value.
Properties
$singleton
Whether this resolver should return a singleton instance.
protected
bool
$singleton
$callback
The callback or value to resolve.
private
mixed
$callback
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
abstract get(Container $container) : mixed
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.