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
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
      • Decorator
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

接口 EventManagerInterface

接口 EventManagerInterface

命名空间: Cake\Event

方法摘要

  • dispatch() public

    将新事件分派给所有已配置的监听器

  • listeners() public

    返回 eventKey 的所有监听器列表,按照其调用顺序排序

  • off() public

    从活动监听器中移除监听器。

  • on() public

    将新监听器添加到事件。

方法详情

dispatch() ¶ public

dispatch(Cake\Event\EventInterface<TSubject>|string $event): Cake\Event\EventInterface<TSubject>

将新事件分派给所有已配置的监听器

参数
Cake\Event\EventInterface<TSubject>|string $event

事件键名称或 EventInterface 实例。

返回
Cake\Event\EventInterface<TSubject>

listeners() ¶ public

listeners(string $eventKey): array

返回 eventKey 的所有监听器列表,按照其调用顺序排序

参数
string $eventKey

事件键。

返回
数组

off() ¶ public

off(Cake\Event\EventListenerInterface|callable|string $eventKey, Cake\Event\EventListenerInterface|callable|null $callable = null): $this

从活动监听器中移除监听器。

完全移除 EventListenerInterface

$manager->off($listener);

移除给定事件的所有监听器

$manager->off('My.event');

移除特定监听器

$manager->off('My.event', $callback);

从所有事件中移除回调

$manager->off($callback);
参数
Cake\Event\EventListenerInterface|callable|string $eventKey

回调关联的事件唯一标识符名称,或您要移除的 $listener。

Cake\Event\EventListenerInterface|callable|null $callable optional

您要分离的回调。

返回
$this

on() ¶ public

on(Cake\Event\EventListenerInterface|string $eventKey, callable|array $options = [], callable|null $callable = null): $this

将新监听器添加到事件。

一个变长参数接口,用来添加模拟 jQuery.on() 的监听器。

绑定 EventListenerInterface

$eventManager->on($listener);

无选项绑定

$eventManager->on('Model.beforeSave', $callable);

使用选项绑定

$eventManager->on('Model.beforeSave', ['priority' => 90], $callable);
参数
Cake\Event\EventListenerInterface|string $eventKey

回调关联的事件唯一标识符名称。如果 $eventKey 是 Cake\Event\EventListenerInterface 的实例,则会使用 implementedEvents() 方法绑定其事件。

callable|array $options optional

一个选项数组或您希望绑定到 $eventKey 的可调用对象。如果是选项数组,则可以使用 priority 键定义顺序。优先级被视为队列。较低的值比较高的值先被调用,并且添加到同一优先级队列的多个附件将按插入顺序处理。

callable|null $callable optional

您希望调用的可调用函数。

返回
$this
抛出
InvalidArgumentException
当事件键丢失或可调用对象不是 Cake\Event\EventListenerInterface 的实例时。
OpenHub
Pingping
Linode
  • 企业解决方案
  • 展示
  • 文档
  • 手册
  • API
  • 视频
  • 报告安全问题
  • 隐私政策
  • 标识和商标
  • 社区
  • 参与进来
  • 问题 (Github)
  • 烘焙坊
  • 精选资源
  • 培训
  • 聚会
  • 我的 CakePHP
  • CakeFest
  • 通讯
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • 帮助与支持
  • 论坛
  • Stack Overflow
  • IRC
  • Slack
  • 付费支持

使用 CakePHP API Docs 生成