Spec-Zone.ru › CakePHP 4.3

Класс Container

Контейнер инъекции зависимостей

Основан на контейнере из League\Container

Пространство имен: Cake\Core
Экспериментально: Ожидаются изменения API в незначительных выпусках.

Краткое описание свойств

  • $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 необязательно

Возвращает

DefinitionInterface

addServiceProvider() public

addServiceProvider(ServiceProviderInterface $provider): self

Параметры

ServiceProviderInterface $provider

Возвращает

self

addShared() public

addShared(string $id, mixed $concrete = null): DefinitionInterface

Параметры

string $id
$concrete необязательно

Возвращает

DefinitionInterface

defaultToShared() public

defaultToShared(bool $shared = true): ContainerInterface

Параметры

bool $shared необязательно

Возвращает

ContainerInterface

delegate() public

delegate(ContainerInterface $container): self

Параметры

ContainerInterface $container

Возвращает

self

extend() public

extend(string $id): DefinitionInterface

Параметры

string $id

Возвращает

DefinitionInterface

get() 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

Идентификатор записи, которую нужно найти.

Возвращает

bool

inflector() public

inflector(string $type, callable $callback = null): InflectorInterface

Параметры

string $type
callable $callback необязательно

Возвращает

InflectorInterface

resolve() 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

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API