1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace backend\controllers;
- use components\Exception;
- use yii\helpers\ArrayHelper;
- use yii\web\Controller;
- class BaseController extends Controller
- {
-
- public function init()
- {
- \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
- parent::init();
- }
-
- public function behaviors()
- {
- return ArrayHelper::merge(parent::behaviors(), [
- 'bearerAuth' => [
- 'class' => \common\filters\auth\BearerAuth::className(),
-
- 'optional' => [
- 'token',
- 'signature',
- 'test',
- ],
- ]
- ] );
- }
-
- public function beforeAction($action)
- {
- try {
- return parent::beforeAction($action);
- } catch (\Exception $e) {
- throw new Exception(isset($e->statusCode) ? $e->statusCode : $e->getCode(), $e->getMessage());
- }
- }
- }
|