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-08-04 03:37:21 +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
|
|
|
/**
|
2016-05-30 23:41:22 +05:30
|
|
|
* Поведения:
|
|
|
|
* @mixin \yii\filters\ContentNegotiator
|
|
|
|
* @mixin \yii\filters\VerbFilter
|
|
|
|
* @mixin \yii\filters\auth\CompositeAuth
|
2016-02-14 23:20:10 +05:30
|
|
|
*/
|
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'] = [
|
2016-05-30 05:14:17 +05:30
|
|
|
'class' => HttpBearerAuth::class,
|
2016-08-04 03:37:21 +05:30
|
|
|
'user' => Yii::$app->getUser(),
|
2016-02-24 03:45:04 +05:30
|
|
|
];
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|