简单理解yii事件

  • 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>';
    }
    }
上一篇:Photoshop绘制金庸《神雕侠侣》


下一篇:Photoshop绘制彩色透明圆球形图标