public function actionIndex(){
echo 'hehe';
exit;
}
我想在在index action之前执行一个action,之后也执行一个action.有什么好的方法呢?类似于thinkPHp中的__before_index(),__after_index() 这种效果。
难道你不知道 Yii2 有 beforeAction
和 afterAction
?
用法你可以看这个 Yii2 自带事件的用法
@wy1272086709 #2楼 你在当前控制器使用,然后使用 $this->action->uniqueId
获取当前 uniqueId
,做判断就可以了,很简单的。