Class ServiceProvider
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.
Property Summary
-
$container protected
Cake\Container\ContainerInterface|null -
$identifier protected
string|null -
$provides protected
array<string>List of ids of services this provider provides.
Method Summary
-
boot() public
Delegate to the bootstrap() method
This method wraps the underlying container's boot() function so users only need to use the CakePHP bootstrap() interface.
-
bootstrap() public
Bootstrap hook for ServiceProviders
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.
-
getContainer() public
-
getIdentifier() public
-
provides() public
The provides method is a way to let the container know that a service is provided by this service provider.
Every service registered via this service provider must have an alias added to this array or it will be ignored.
-
register() public
Call the abstract services() method.
This method primarily exists as a shim between the interface that the underlying container has and the one we want to offer in CakePHP.
-
services() abstract public
Register the services in a provider.
All services registered in this method should also be included in the $provides property so that services can be located.
-
setContainer() public
-
setIdentifier() public
Method Detail
boot() ¶ public
boot(): void
Delegate to the bootstrap() method
This method wraps the underlying container's boot() function so users only need to use the CakePHP bootstrap() interface.
Returns
voidbootstrap() ¶ public
bootstrap(Cake\Container\ContainerInterface $container): void
Bootstrap hook for ServiceProviders
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
-
Cake\Container\ContainerInterface$container The container to add services to.
Returns
voidgetContainer() ¶ public
getContainer(): Cake\Container\ContainerInterface
Returns
Cake\Container\ContainerInterfaceprovides() ¶ public
provides(string $id): bool
The provides method is a way to let the container know that a service is provided by this service provider.
Every service registered via this service provider must have an alias added to this array or it will be ignored.
Parameters
-
string$id Identifier.
Returns
boolregister() ¶ public
register(): void
Call the abstract services() method.
This method primarily exists as a shim between the interface that the underlying container has and the one we want to offer in CakePHP.
Returns
voidservices() ¶ abstract public
services(Cake\Container\ContainerInterface $container): void
Register the services in a provider.
All services registered in this method should also be included in the $provides property so that services can be located.
Parameters
-
Cake\Container\ContainerInterface$container The container to add services to.
Returns
voidsetContainer() ¶ public
setContainer(Cake\Container\ContainerInterface $container): $this
Parameters
-
Cake\Container\ContainerInterface$container
Returns
$this