Класс Container
Контейнер инъекции зависимостей
Основан на контейнере из League\Container
Краткое описание свойств
- $defaultToShared protected
boolean - $definitions protected
DefinitionAggregateInterface - $delegates protected
ContainerInterface[] - $inflectors protected
InflectorAggregateInterface - $providers protected
ServiceProviderAggregateInterface
Краткое описание методов
-
__construct() public
-
add() public
-
addServiceProvider() public
-
addShared() public
-
defaultToShared() public
-
delegate() public
-
extend() public
-
get() public
Находит запись в контейнере по её идентификатору и возвращает её.
-
getNew() public
-
has() public
Возвращает true, если контейнер может вернуть запись для данного идентификатора. В противном случае возвращает false.
-
inflector() public
-
resolve() protected
Подробное описание методов
__construct() public
__construct(DefinitionAggregateInterface $definitions = null, ServiceProviderAggregateInterface $providers = null, InflectorAggregateInterface $inflectors = null)
Параметры
-
DefinitionAggregateInterface$definitions необязательно -
ServiceProviderAggregateInterface$providers необязательно -
InflectorAggregateInterface$inflectors необязательно
add() public
add(string $id, mixed $concrete = null): DefinitionInterface
Параметры
-
string$id - $concrete необязательно
Возвращает
DefinitionInterfaceaddServiceProvider() public
addServiceProvider(ServiceProviderInterface $provider): self
Параметры
-
ServiceProviderInterface$provider
Возвращает
selfaddShared() public
addShared(string $id, mixed $concrete = null): DefinitionInterface
Параметры
-
string$id - $concrete необязательно
Возвращает
DefinitionInterfacedefaultToShared() public
defaultToShared(bool $shared = true): ContainerInterface
Параметры
-
bool$shared необязательно
Возвращает
ContainerInterfacedelegate() public
delegate(ContainerInterface $container): self
Параметры
-
ContainerInterface$container
Возвращает
selfextend() public
extend(string $id): DefinitionInterface
Параметры
-
string$id
Возвращает
DefinitionInterfaceget() public
get(string $id): mixed
Находит запись в контейнере по ее идентификатору и возвращает ее.
Параметры
-
string$id Идентификатор записи, которую нужно найти.
Возвращает
mixedВыбрасывает
NotFoundExceptionInterfaceЗапись с **этим** идентификатором не найдена.
ContainerExceptionInterfaceОшибка при получении записи.
getNew() public
getNew(mixed $id)
Параметры
- $id
has() public
has(string $id): bool
Возвращает true, если для данного идентификатора контейнер может вернуть запись. В противном случае возвращает false.
has($id) возвращение true не означает, что get($id) не выбросит исключение. Однако это означает, что get($id) не выбросит NotFoundExceptionInterface.
Параметры
-
string$id Идентификатор записи, которую нужно найти.
Возвращает
boolinflector() public
inflector(string $type, callable $callback = null): InflectorInterface
Параметры
-
string$type -
callable$callback необязательно
Возвращает
InflectorInterfaceresolve() protected
resolve(mixed $id, bool $new = false)
Параметры
- $id
-
bool$new необязательно
Подробное описание свойств
$defaultToShared защищенное
Тип
boolean$definitions защищенное
Тип
DefinitionAggregateInterface$delegates защищенное
Тип
ContainerInterface[]$inflectors защищенное
Тип
InflectorAggregateInterface$providers защищенное
Тип
ServiceProviderAggregateInterface
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.3/class-Cake.Core.Container.html