/** * Set custom denyCallback */ public function init() { $this->denyCallback = function () { throw new ApiException(Code::USER_PERMISSION_DENIED); }; parent::init(); }
/** * @inheritdoc */ public function behaviors() { return ['access' => ['class' => AccessControl::className(), 'rules' => [['allow' => true, 'roles' => ['user']]], 'denyCallback' => function () { throw new ApiException(Code::USER_PERMISSION_DENIED); }]]; }
/** * @inheritdoc */ public function behaviors() { return ['access' => ['class' => AccessControl::className(), 'only' => ['logout'], 'rules' => [['allow' => true, 'roles' => ['user']]]]]; }
/** * @inheritdoc */ public function behaviors() { return ArrayHelper::merge(parent::behaviors(), ['access' => ['class' => AccessControl::className(), 'rules' => [['allow' => true, 'roles' => ['user']]]]]); }