Interface ContainerInterface
Interface for the Dependency Injection Container in CakePHP applications
This interface extends the PSR-11 container interface and adds methods to add services and service providers to the container.
The methods defined in this interface use the conventions provided by league/container as that is the library that CakePHP uses.
Method Summary
-
add() public
-
addServiceProvider() public
-
addShared() public
-
extend() public
-
get() public
Finds an entry of the container by its identifier and returns it.
-
getNew() public
-
has() public
Returns true if the container can return an entry for the given identifier. Returns false otherwise.
-
inflector() public
Method Detail
add() ¶ public
add(string $id, mixed $concrete = null): DefinitionInterface
Parameters
-
string$id -
$concrete optional
Returns
DefinitionInterfaceaddServiceProvider() ¶ public
addServiceProvider(ServiceProviderInterface $provider): self
Parameters
-
ServiceProviderInterface$provider
Returns
selfaddShared() ¶ public
addShared(string $id, mixed $concrete = null): DefinitionInterface
Parameters
-
string$id -
$concrete optional
Returns
DefinitionInterfaceextend() ¶ public
extend(string $id): DefinitionInterface
Parameters
-
string$id
Returns
DefinitionInterfaceget() ¶ public
get(string $id): mixed
Finds an entry of the container by its identifier and returns it.
Parameters
-
string$id Identifier of the entry to look for.
Returns
mixedEntry.
Throws
NotFoundExceptionInterfaceNo entry was found for **this** identifier.
ContainerExceptionInterfaceError while retrieving the entry.
has() ¶ public
has(string $id): bool
Returns true if the container can return an entry for the given identifier. Returns false otherwise.
has($id) returning true does not mean that get($id) will not throw an exception.
It does however mean that get($id) will not throw a NotFoundExceptionInterface.
Parameters
-
string$id Identifier of the entry to look for.
Returns
boolinflector() ¶ public
inflector(string $type, ?callable $callback = null): InflectorInterface
Parameters
-
string$type -
?callable$callback optional
Returns
InflectorInterface