Класс 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 protected
Тип
boolean$definitions protected
Тип
DefinitionAggregateInterface$delegates protected
Тип
ContainerInterface[]$inflectors protected
Тип
InflectorAggregateInterface$providers protected
Тип
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.4/class-Cake.Core.Container.html