ServiceProviderRegistry implements IteratorAggregate
A class that holds the list of service providers of a project.
This class is designed so that service provider do not need to be instantiated each time the registry is filled. They can be lazily instantiated if needed.
Table of Contents
Interfaces
- IteratorAggregate
 
Methods
- __construct() : mixed
 - Initializes the registry from a list of service providers.
 - createService() : mixed
 - extendService() : mixed
 - get() : ServiceProviderInterface
 - Returns service provider by id.
 - getExtensions() : array<string|int, mixed>
 - Returns the result of the getExtensions call on service provider whose key in the registry is $packageKey.
 - getFactories() : array<string|int, mixed>
 - Returns the result of the getFactories call on service provider whose key in the registry is $packageKey.
 - getIterator() : Generator
 - has() : bool
 - Whether an id exists.
 
Methods
__construct()
Initializes the registry from a list of service providers.
    public
                    __construct(PackageManager $packageManager[, bool $failsafe = false ]) : mixed
    This list of service providers can be passed as ServiceProvider instances, class name string, or an array of ['class name', [constructor params...]].
Parameters
- $packageManager : PackageManager
 - $failsafe : bool = false
 
createService()
    public
                    createService(string $packageKey, string $serviceName, ContainerInterface $container) : mixed
    Parameters
- $packageKey : string
 - 
                    
Key of the service provider in the registry
 - $serviceName : string
 - 
                    
Name of the service to fetch
 - $container : ContainerInterface
 
extendService()
    public
                    extendService(string $packageKey, string $serviceName, ContainerInterface $container[, mixed $previous = null ]) : mixed
    Parameters
- $packageKey : string
 - 
                    
Key of the service provider in the registry
 - $serviceName : string
 - 
                    
Name of the service to fetch
 - $container : ContainerInterface
 - $previous : mixed = null
 
get()
Returns service provider by id.
    public
                    get(string $packageKey) : ServiceProviderInterface
    Parameters
- $packageKey : string
 - 
                    
Key of the service provider in the registry
 
Return values
ServiceProviderInterfacegetExtensions()
Returns the result of the getExtensions call on service provider whose key in the registry is $packageKey.
    public
                    getExtensions(string $packageKey) : array<string|int, mixed>
    The result is cached in the registry so two successive calls will trigger getExtensions only once.
Parameters
- $packageKey : string
 - 
                    
Key of the service provider in the registry
 
Return values
array<string|int, mixed>getFactories()
Returns the result of the getFactories call on service provider whose key in the registry is $packageKey.
    public
                    getFactories(string $packageKey) : array<string|int, mixed>
    The result is cached in the registry so two successive calls will trigger getFactories only once.
Parameters
- $packageKey : string
 - 
                    
Key of the service provider in the registry
 
Return values
array<string|int, mixed>getIterator()
    public
                    getIterator() : Generator
    Return values
Generatorhas()
Whether an id exists.
    public
                    has(string $packageKey) : bool
    Parameters
- $packageKey : string
 - 
                    
Key of the service provider in the registry
 
Return values
bool —true on success or false on failure.