疑惑不解這一段的內(nèi)容https://github.com/yiisoft/yii2/blob/master/docs/guide/concept-events....,里面一直在不斷的強調(diào)說事件Event的綁定:php$foo=newFoo;//thishandlerisaglobalfunction$foo->on(Foo::EVENT_HELLO,'function_name');//thishandlerisanobjectmethod$foo->on(Foo::EVENT_HELLO,[$object,'methodName']);//thishandlerisastaticclassmethod$foo->on(Foo::EVENT_HELLO,['app\components\Bar','methodName']);//thishandlerisananonymousfunction$foo->on(Foo::EVENT_HELLO,function($event){//eventhandlinglogic});問題是1)這一段代碼是放在哪里?放在publicfunctionactionXXX(){}里面嗎?2)我想讓除admin的action之外的網(wǎng)站里面所有action在執(zhí)行前都進行對會員是否登錄,已登錄會員是否已經(jīng)創(chuàng)建了日志的檢測,如何實現(xiàn)這個?
如何理解yii2的 Event?全局綁定,特別疑惑
慕慕森
2019-04-10 20:48:38