CakePHP
  • 文档
    • 书籍
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 标识和商标
  • 商业解决方案
  • 周边商品
  • 公路旅行
  • 团队
  • 社区
    • 社区
    • 参与
    • 问题(GitHub)
    • 烘焙坊
    • 精选资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 新闻通讯
    • 领英
    • YouTube
    • 脸书
    • 推特
    • Mastodon
    • 帮助和支持
    • 论坛
    • Stack Overflow
    • IRC
    • Slack
    • 付费支持
CakePHP

C CakePHP 5.1 Chiffon API

  • 项目
    • CakePHP
      • CakePHP
      • Chronos
      • Elastic Search
      • 队列
  • 版本
    • 5.1
      • 5.1
      • 5.0
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

命名空间

  • 全局
  • Cake
    • 缓存
    • 集合
    • 命令
    • 控制台
    • 控制器
    • 核心
      • 配置
      • 异常
      • 重试
      • 测试套件
    • 数据库
    • 数据源
    • 错误
    • 事件
    • 表单
    • Http
    • 国际化
    • 日志
    • 邮件
    • 网络
    • ORM
    • 路由
    • 测试套件
    • 实用工具
    • 验证
    • 视图

类容器

依赖注入容器

基于 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
返回值
DefinitionInterface

addServiceProvider() ¶ public

addServiceProvider(ServiceProviderInterface $provider): self
参数
ServiceProviderInterface $provider
返回值
self

addShared() ¶ public

addShared(string $id, mixed $concrete = null): DefinitionInterface
参数
string $id
$concrete optional
返回值
DefinitionInterface

defaultToShared() ¶ public

defaultToShared(bool $shared = true): ContainerInterface
参数
bool $shared optional
返回值
ContainerInterface

delegate() ¶ public

delegate(Psr\Container\ContainerInterface $container): Psr\Container\ContainerInterface
参数
Psr\Container\ContainerInterface $container

要使用作委托的容器实例

返回值
Psr\Container\ContainerInterface

extend() ¶ public

extend(string $id): DefinitionInterface
参数
string $id
返回值
DefinitionInterface

get() ¶ public

get(string $id): mixed

通过其标识符查找容器的条目并返回它。

参数
string $id

要查找的条目的标识符。

返回值
混合
抛出
NotFoundExceptionInterface
未找到 **此** 标识符的条目。
ContainerExceptionInterface
检索条目时出错。

getNew() ¶ public

getNew(mixed $id): RequestedType|mixed
参数
$id
返回值
RequestedType|混合

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

resolve() ¶ protected

resolve(mixed $id, bool $new = false)
参数
$id
bool $new optional

属性详情

$defaultToShared ¶ protected

类型
布尔值

$definitions ¶ protected

类型
DefinitionAggregateInterface

$delegates ¶ protected

类型
ContainerInterface[]

$inflectors ¶ protected

类型
InflectorAggregateInterface

$providers ¶ protected

类型
ServiceProviderAggregateInterface
OpenHub
Pingping
Linode
  • 商业解决方案
  • 展示
  • 文档
  • 书籍
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 标识和商标
  • 社区
  • 参与
  • 问题(GitHub)
  • 烘焙坊
  • 精选资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 新闻通讯
  • 领英
  • YouTube
  • 脸书
  • 推特
  • Mastodon
  • 帮助和支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成