ServiceProvider
extends AbstractServiceProvider
in package
implements
BootableServiceProviderInterface
Container ServiceProvider
Service provider bundle related services together helping to organize your application's dependencies. They also help improve performance of applications with many services by allowing service registration to be deferred until services are needed.
Table of Contents
Interfaces
Properties
- $container : DefinitionContainerInterface|null
- $identifier : string
- $provides : array<string|int, string>
- List of ids of services this provider provides.
Methods
- boot() : void
- Delegate to the bootstrap() method
- bootstrap() : void
- Bootstrap hook for ServiceProviders
- getContainer() : ContainerInterface
- Get the container.
- getIdentifier() : string
- provides() : bool
- The provides method is a way to let the container know that a service is provided by this service provider.
- register() : void
- Call the abstract services() method.
- services() : void
- Register the services in a provider.
- setContainer() : ContainerAwareInterface
- setIdentifier() : ServiceProviderInterface
Properties
$container
protected
DefinitionContainerInterface|null
$container
$identifier
protected
string
$identifier
$provides
List of ids of services this provider provides.
protected
array<string|int, string>
$provides
= []
Tags
Methods
boot()
Delegate to the bootstrap() method
public
boot() : void
This method wraps the league/container function so users only need to use the CakePHP bootstrap() interface.
bootstrap()
Bootstrap hook for ServiceProviders
public
bootstrap(ContainerInterface $container) : void
This hook should be implemented if your service provider needs to register additional service providers, load configuration files or do any other work when the service provider is added to the container.
Parameters
- $container : ContainerInterface
-
The container to add services to.
getContainer()
Get the container.
public
getContainer() : ContainerInterface
This method's actual return type and documented return type differ because PHP 7.2 doesn't support return type narrowing.
Return values
ContainerInterfacegetIdentifier()
public
getIdentifier() : string
Return values
stringprovides()
The provides method is a way to let the container know that a service is provided by this service provider.
public
provides(string $id) : bool
Every service that is registered via this service provider must have an alias added to this array or it will be ignored.
Parameters
- $id : string
-
Identifier.
Return values
boolregister()
Call the abstract services() method.
public
register() : void
This method primarily exists as a shim between the interface that league/container has and the one we want to offer in CakePHP.
services()
Register the services in a provider.
public
abstract services(ContainerInterface $container) : void
All services registered in this method should also be included in the $provides property so that services can be located.
Parameters
- $container : ContainerInterface
-
The container to add services to.
setContainer()
public
setContainer(DefinitionContainerInterface $container) : ContainerAwareInterface
Parameters
- $container : DefinitionContainerInterface
Return values
ContainerAwareInterfacesetIdentifier()
public
setIdentifier(string $id) : ServiceProviderInterface
Parameters
- $id : string