CakePHP
  • 文档
    • 书籍
    • API
    • 视频
    • 报告安全问题
    • 隐私政策
    • 标识和商标
  • 企业解决方案
  • 周边商品
  • 公路旅行
  • 团队
  • 社区
    • 社区
    • 参与进来
    • 问题 (Github)
    • 烘焙坊
    • 精选资源
    • 培训
    • 聚会
    • 我的 CakePHP
    • CakeFest
    • 通讯
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • 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
    • 路由
    • 测试套件
    • 工具
    • 验证
    • 视图

类 ServiceProvider

容器 ServiceProvider

服务提供者捆绑相关的服务在一起,有助于组织应用程序的依赖关系。它们还通过允许服务注册延迟到需要服务时,帮助提高具有许多服务的应用程序的性能。

抽象
命名空间: Cake\Core

属性摘要

  • $container protected
    ?DefinitionContainerInterface
  • $identifier protected
    string
  • $provides protected
    list<string>

    此提供者提供的服务的 ID 列表。

方法摘要

  • boot() public

    委托给 bootstrap() 方法

  • bootstrap() public

    服务提供者的引导钩子

  • getContainer() public

    获取容器。

  • getIdentifier() public
  • provides() public

    provides 方法是一种让容器知道此服务提供者提供了服务的机制。

  • register() public

    调用抽象 services() 方法。

  • services() abstract public

    在提供者中注册服务。

  • setContainer() public
  • setIdentifier() public

方法详情

boot() ¶ public

boot(): void

委托给 bootstrap() 方法

此方法包装了 league/container 函数,因此用户只需要使用 CakePHP 的 bootstrap() 接口。

返回值
void

bootstrap() ¶ public

bootstrap(Cake\Core\ContainerInterface $container): void

服务提供者的引导钩子

如果您的服务提供者需要注册其他服务提供者、加载配置文件或在服务提供者添加到容器时执行任何其他工作,则应实现此钩子。

参数
Cake\Core\ContainerInterface $container

要添加服务的容器。

返回值
void

getContainer() ¶ public

getContainer(): Cake\Core\ContainerInterface

获取容器。

返回值
Cake\Core\ContainerInterface

getIdentifier() ¶ public

getIdentifier(): string
返回值
string

provides() ¶ public

provides(string $id): bool

provides 方法是一种让容器知道此服务提供者提供了服务的机制。

通过此服务提供者注册的每个服务都必须在此数组中添加别名,否则它将被忽略。

参数
string $id

标识符。

返回值
bool

register() ¶ public

register(): void

调用抽象 services() 方法。

此方法主要作为 league/container 拥有的接口和我们希望在 CakePHP 中提供的接口之间的垫片。

返回值
void

services() ¶ abstract public

services(Cake\Core\ContainerInterface $container): void

在提供者中注册服务。

在此方法中注册的所有服务也应包含在 $provides 属性中,以便可以找到服务。

参数
Cake\Core\ContainerInterface $container

要添加服务的容器。

返回值
void

setContainer() ¶ public

setContainer(DefinitionContainerInterface $container): ContainerAwareInterface
参数
DefinitionContainerInterface $container
返回值
ContainerAwareInterface

setIdentifier() ¶ public

setIdentifier(string $id): ServiceProviderInterface
参数
string $id
返回值
ServiceProviderInterface

属性详情

$container ¶ protected

类型
?DefinitionContainerInterface

$identifier ¶ protected

类型
string

$provides ¶ protected

此提供者提供的服务的 ID 列表。

类型
list<string>
OpenHub
Pingping
Linode
  • 企业解决方案
  • 展示
  • 文档
  • 书籍
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 标识和商标
  • 社区
  • 参与进来
  • 问题 (Github)
  • 烘焙坊
  • 精选资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 通讯
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • 帮助和支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API 文档 生成