123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- namespace backend\controllers;
- use components\Exception;
- use yii\web\Controller;
- /**
- * Class BaseController
- * @package backend\controllers
- */
- class BaseController extends Controller
- {
- /**
- * init
- */
- public function init()
- {
- \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
- parent::init();
- }
- /**
- * beforeAction
- * @return bool
- * @throws Exception
- */
- public function beforeAction($action)
- {
- try {
- return parent::beforeAction($action);
- } catch (\Exception $e) {
- throw new Exception($e->statusCode, $e->getMessage());
- }
- }
- }
|