- https://blog.csdn.net/qq43599939/article/details/80363827 通过观察者来理解yii事件
- 测试
class TestController extends Controller
{
const EVENT_MY_EVENT = 'myEvent'; public function actionTest()
{
echo 'this is test action<br>';
$myEvent = new MyEvent();
$this->on(self::EVENT_MY_EVENT, ['app\modules\api\event\MyEvent', 'fooEvent']); //绑定事件
$this->trigger(self::EVENT_MY_EVENT, $myEvent); //触发
}
} //事件类
class MyEvent extends Event
{
public function fooEvent()
{
echo 'this is my first event instance.<br>';
}
}
相关文章
- 10-15对Springdata模块的简单理解
- 10-15事件捕获和事件冒泡理解
- 10-15理解事件冒泡和事件捕获
- 10-15简单理解scala的闭包
- 10-15主题模型(LDA)(一)--通俗理解与简单应用
- 10-15简单理解 addAll(Collection extends E> c) 方法
- 10-15sql语句 group by方法简单理解
- 10-15选择排序简单理解
- 10-15Symbol.Iterator简单理解
- 10-15k-means 聚类的简单理解