Interface DefinitionContainerInterface
Method Summary
-
add() public
-
addDefinitions() public
Add multiple definitions at once.
-
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.
-
hasDefinition() public
Check if the container has a registered definition for the given id.
-
inflector() public
Method Detail
add() ¶ public
add(string $id, mixed $concrete = null): Cake\Container\Definition\DefinitionInterface
Parameters
-
string$id -
mixed$concrete optional
Returns
Cake\Container\Definition\DefinitionInterfaceaddDefinitions() ¶ public
addDefinitions(array<int|string, array<class-string>|class-string> $definitions): self
Add multiple definitions at once.
Supports multiple formats:
[Foo::class]- class name as value, registers as itself['alias' => Foo::class]- alias as key, class as value[Foo::class => [Bar::class]]- class with constructor arguments
Parameters
-
array<int|string, array<class-string>|class-string>$definitions
Returns
selfaddServiceProvider() ¶ public
addServiceProvider(Cake\Container\ServiceProvider\ServiceProviderInterface $provider): self
Parameters
-
Cake\Container\ServiceProvider\ServiceProviderInterface$provider
Returns
selfaddShared() ¶ public
addShared(string $id, mixed $concrete = null): Cake\Container\Definition\DefinitionInterface
Parameters
-
string$id -
mixed$concrete optional
Returns
Cake\Container\Definition\DefinitionInterfaceextend() ¶ public
extend(string $id): Cake\Container\Definition\DefinitionInterface
Parameters
-
string$id
Returns
Cake\Container\Definition\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
boolhasDefinition() ¶ public
hasDefinition(string $id): bool
Check if the container has a registered definition for the given id.
Unlike has(), this only checks explicit definitions, not service providers
or delegate containers.
Parameters
-
string$id
Returns
boolinflector() ¶ public
inflector(string $type, callable|null $callback = null): Cake\Container\Inflector\InflectorInterface
Parameters
-
string$type -
callable|null$callback optional
Returns
Cake\Container\Inflector\InflectorInterface