AggregateServiceProvider

Class
implements ServiceProviderInterface

Aggregates multiple service providers into a single provider.

Description

This class MUST be used to compose a unified list of factories and extensions from several ServiceProviderInterface implementations.

Factories and extensions returned by this class are merged in registration order.

Table of Contents

Interfaces

Properties

 : array<string|int, ServiceProviderInterface>

Methods

__construct()

Constructs the AggregateServiceProvider.

 : mixed
getExtensions()

Retrieves all service extensions from aggregated providers.

 : array<string, callable>
getFactories()

Retrieves all service factories from aggregated providers.

 : array<string, callable>
Properties

$serviceProviders

Private Read-only
private array<string|int, ServiceProviderInterface> $serviceProviders

Description

list of service providers to aggregate

Methods

__construct()

Public

Constructs the AggregateServiceProvider.

public __construct(ServiceProviderInterface  ...$serviceProviders) : mixed
Parameters
$serviceProviders : ServiceProviderInterface

Description

One or more service providers to aggregate.

getExtensions()

Public

Retrieves all service extensions from aggregated providers.

public getExtensions() : array<string, callable>

Description

This method merges extensions from each provider. If multiple extensions exist for the same service ID, they are composed in the order they are added using nested closures.

Tags
throws
RuntimeException

Description

if any extension is not callable

Return values
array<string, callable>

Description

an associative array of service extensions

getFactories()

Public

Retrieves all service factories from aggregated providers.

public getFactories() : array<string, callable>

Description

This method merges the factories from each service provider into a single array. The factory for this class itself is added under the key of its class name.

Return values
array<string, callable>

Description

an associative array of service factories