类容器
依赖注入容器
基于 League\Container 中的容器
命名空间: Cake\Core
属性摘要
-
$defaultToShared protected
布尔值 -
$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 optional -
ServiceProviderAggregateInterface$providers optional -
InflectorAggregateInterface$inflectors optional
add() ¶ public
add(string $id, mixed $concrete = null): DefinitionInterface
参数
-
string$id -
$concrete optional
返回值
DefinitionInterfaceaddServiceProvider() ¶ public
addServiceProvider(ServiceProviderInterface $provider): self
参数
-
ServiceProviderInterface$provider
返回值
selfaddShared() ¶ public
addShared(string $id, mixed $concrete = null): DefinitionInterface
参数
-
string$id -
$concrete optional
返回值
DefinitionInterfacedefaultToShared() ¶ public
defaultToShared(bool $shared = true): ContainerInterface
参数
-
bool$shared optional
返回值
ContainerInterfacedelegate() ¶ public
delegate(Psr\Container\ContainerInterface $container): Psr\Container\ContainerInterface
参数
-
Psr\Container\ContainerInterface$container 要使用作委托的容器实例
返回值
Psr\Container\ContainerInterfaceget() ¶ public
get(string $id): mixed
通过其标识符查找容器的条目并返回它。
参数
-
string$id 要查找的条目的标识符。
返回值
混合抛出
NotFoundExceptionInterface未找到 **此** 标识符的条目。
ContainerExceptionInterface检索条目时出错。
has() ¶ public
has(string $id): bool
如果容器可以为给定的标识符返回一个条目,则返回 true。否则返回 false。
has($id) 返回 true 并不意味着 get($id) 不会抛出异常。但是,它确实意味着 get($id) 不会抛出 NotFoundExceptionInterface。
参数
-
string$id 要查找的条目的标识符。
返回值
布尔值inflector() ¶ public
inflector(string $type, callable $callback = null): InflectorInterface
参数
-
string$type -
callable$callback optional
返回值
InflectorInterface