我正在尝试在控制器中执行 afterAction 事件,但没有发生任何事情(该函数未被调用)。这是 afterAction 的代码:
public function afterAction($action, $result)
{
$result = parent::afterAction($action, $result);
$this->_logDownloadActivity();
return $result;
}
我试图打电话的功能:
private function _logDownloadActivity()
{
$model = new ActivityLogsUserActivity();
$model->user_id = Yii::$app->user->identity->id;
$model->userActivityType_id = 3;
$model->buildVersion = 3333;
$model->ipAddress = $model->userIP();
$model->insert();
}