AggregateContainer
in package
implements
ContainerInterface
Aggregates multiple PSR-11 containers and delegates resolution requests among them.
This container implementation respects PSR-11 expectations and throws a NotFoundException when a requested service cannot be found in any delegated container.
It caches resolved entries to prevent redundant calls to delegated containers.
Table of Contents
Interfaces
- ContainerInterface
- Extends the PSR-11 ContainerInterface to provide a consistent, domain-specific container interface for the FastForward ecosystem.
Constants
- ALIAS = 'container'
Methods
- __construct() : mixed
- Constructs the AggregateContainer with one or more delegated containers.
- append() : void
- Appends a container to the end of the aggregated list.
- get() : mixed
- Retrieves the entry associated with the given identifier.
- has() : bool
- Determines whether a service identifier can be resolved.
- prepend() : void
- Prepends a container to the beginning of the aggregated list.
Constants
ALIAS
public
string
ALIAS
= 'container'
container alias for reference binding
Methods
__construct()
Constructs the AggregateContainer with one or more delegated containers.
public
__construct(ContainerInterface ...$containers) : mixed
The constructor SHALL bind itself to common aliases, including the class name and the PSR-11 interface, to simplify resolution of the container itself.
Parameters
- $containers : ContainerInterface
-
One or more container implementations to aggregate.
append()
Appends a container to the end of the aggregated list.
public
append(ContainerInterface $container) : void
This method MAY be used to dynamically expand the resolution pool.
Parameters
- $container : ContainerInterface
-
the container to append
get()
Retrieves the entry associated with the given identifier.
public
get(string $id) : mixed
This method SHALL resolve from its internal cache first, and otherwise iterate through the aggregated containers to resolve the entry. It MUST throw a NotFoundException if the identifier cannot be resolved.
Parameters
- $id : string
-
the identifier of the entry to retrieve
Tags
Return values
mixed —the resolved entry
has()
Determines whether a service identifier can be resolved.
public
has(string $id) : bool
This method SHALL return true if the identifier is pre-resolved or can be located in any of the aggregated containers.
Parameters
- $id : string
-
the identifier of the entry to look for
Return values
bool —true if the entry exists, false otherwise
prepend()
Prepends a container to the beginning of the aggregated list.
public
prepend(ContainerInterface $container) : void
This method MAY be used to prioritize a container during resolution.
Parameters
- $container : ContainerInterface
-
the container to prepend