2016-01-03 05:48:37 +05:30
|
|
|
<?php
|
|
|
|
namespace api\controllers;
|
|
|
|
|
2016-01-15 14:51:27 +05:30
|
|
|
use api\traits\ApiNormalize;
|
2016-02-14 23:20:10 +05:30
|
|
|
use Yii;
|
2016-02-24 03:45:04 +05:30
|
|
|
use yii\filters\auth\HttpBearerAuth;
|
2016-01-03 05:48:37 +05:30
|
|
|
|
2016-02-14 23:20:10 +05:30
|
|
|
/**
|
|
|
|
* @property \common\models\Account|null $account
|
|
|
|
*/
|
2016-01-03 05:48:37 +05:30
|
|
|
class Controller extends \yii\rest\Controller {
|
2016-01-15 14:51:27 +05:30
|
|
|
use ApiNormalize;
|
2016-01-03 05:48:37 +05:30
|
|
|
|
|
|
|
public function behaviors() {
|
|
|
|
$parentBehaviors = parent::behaviors();
|
2016-02-24 03:45:04 +05:30
|
|
|
// Добавляем авторизатор для входа по jwt токенам
|
|
|
|
$parentBehaviors['authenticator'] = [
|
|
|
|
'class' => HttpBearerAuth::className(),
|
|
|
|
];
|
|
|
|
|
2016-01-03 05:48:37 +05:30
|
|
|
// xml нам не понадобится
|
|
|
|
unset($parentBehaviors['contentNegotiator']['formats']['application/xml']);
|
2016-02-24 03:45:04 +05:30
|
|
|
// rate limiter здесь не применяется
|
|
|
|
unset($parentBehaviors['rateLimiter']);
|
2016-01-03 05:48:37 +05:30
|
|
|
|
|
|
|
return $parentBehaviors;
|
|
|
|
}
|
|
|
|
|
2016-02-14 23:20:10 +05:30
|
|
|
/**
|
|
|
|
* @return \common\models\Account|null
|
|
|
|
*/
|
|
|
|
public function getAccount() {
|
|
|
|
return Yii::$app->getUser()->getIdentity();
|
|
|
|
}
|
|
|
|
|
2016-01-03 05:48:37 +05:30
|
|
|
}
|