疑惑不解
这一段的内容 https://github.com/yiisoft/yii2/blob/master/docs/guide/concept-events....,里面一直在不断的强调说事件Event的绑定:
php
$foo = new Foo; // this handler is a global function $foo->on(Foo::EVENT_HELLO, 'function_name'); // this handler is an object method $foo->on(Foo::EVENT_HELLO, [$object, 'methodName']); // this handler is a static class method $foo->on(Foo::EVENT_HELLO, ['app\components\Bar', 'methodName']); // this handler is an anonymous function $foo->on(Foo::EVENT_HELLO, function ($event) { // event handling logic });
问题是
1)这一段代码是放在哪里?放在 public function actionXXX(){}
里面吗?
2)我想让除admin的action之外的网站里面所有action在执行前都进行对会员是否登录,已登录会员是否已经创建了日志的检测,如何实现这个?
Yii::$app->user->login()
执行前进行绑定