[ 'class' => ContentNegotiator::className(), 'formats' => [ 'application/json' => Response::FORMAT_JSON ], ], 'verbFilter' => [ 'class' => VerbFilter::className(), 'actions' => $this->verbs(), ], 'rateLimiter' => [ 'class' => RateLimiter::className(), ], ]; } /** * 所有小程序端的API请求均需要调用handleMallAccessCtrl * @param \yii\base\Action $action * @return bool * @throws \yii\web\BadRequestHttpException */ public function beforeAction($action) { if (!parent::beforeAction($action)) { return false; } return true; } /** * 获取ClientUserId * @return int */ public function getClientUserId() { return Yii::$app->user->id; } /** * @throws Exception */ public function init() { parent::init(); $this->request = Yii::$app->getRequest(); $this->response = Yii::$app->getResponse(); $this->user = Yii::$app->getUser(); } }