2016-01-03 05:48:37 +05:30
|
|
|
<?php
|
|
|
|
namespace api\controllers;
|
|
|
|
|
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 {
|
|
|
|
|
2017-09-19 22:36:16 +05:30
|
|
|
public function behaviors(): array {
|
2016-01-03 05:48:37 +05:30
|
|
|
$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-11-30 23:27:30 +05:30
|
|
|
// xml и rate limiter нам не понадобятся
|
|
|
|
unset(
|
|
|
|
$parentBehaviors['contentNegotiator']['formats']['application/xml'],
|
|
|
|
$parentBehaviors['rateLimiter']
|
|
|
|
);
|
2016-01-03 05:48:37 +05:30
|
|
|
|
|
|
|
return $parentBehaviors;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|