在yii2中的事件概念

时间:2017-04-25 18:28:54

标签: events yii2

我已经完成了以下指南: http://www.yiiframework.com/doc-2.0/guide-concept-events.html

但我在这里有一个简单的困惑:

//这个处理程序是一个静态类方法 $ foo-> on(Foo :: EVENT_HELLO,['app \ components \ Bar','methodName']);

上述事件将在执行方法时被触发:'app \ components \ Bar'的'methodName'?

OR

方法:类'app \ components \ Bar'的'methodName'将在上述事件的调用中触发?

1 个答案:

答案 0 :(得分:0)

方法:' methodName'类&app;组件\栏\&39;将在上述事件的召唤下解雇。

要在执行方法时触发事件,您必须触发事件 - http://www.yiiframework.com/doc-2.0/guide-concept-events.html#triggering-events