2016-01-03 03:18:37 +03:00
|
|
|
<?php
|
2019-07-15 01:59:56 +03:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2016-01-03 03:18:37 +03:00
|
|
|
namespace api\controllers;
|
|
|
|
|
2016-08-04 01:07:21 +03:00
|
|
|
use Yii;
|
2016-02-24 01:15:04 +03:00
|
|
|
use yii\filters\auth\HttpBearerAuth;
|
2016-01-03 03:18:37 +03:00
|
|
|
|
2016-02-14 20:50:10 +03:00
|
|
|
/**
|
2019-07-15 01:59:56 +03:00
|
|
|
* Behaviors:
|
2016-05-30 21:11:22 +03:00
|
|
|
* @mixin \yii\filters\ContentNegotiator
|
|
|
|
* @mixin \yii\filters\VerbFilter
|
|
|
|
* @mixin \yii\filters\auth\CompositeAuth
|
2016-02-14 20:50:10 +03:00
|
|
|
*/
|
2016-01-03 03:18:37 +03:00
|
|
|
class Controller extends \yii\rest\Controller {
|
|
|
|
|
2017-09-19 20:06:16 +03:00
|
|
|
public function behaviors(): array {
|
2016-01-03 03:18:37 +03:00
|
|
|
$parentBehaviors = parent::behaviors();
|
2019-07-15 01:59:56 +03:00
|
|
|
// Add JWT authenticator
|
2016-02-24 01:15:04 +03:00
|
|
|
$parentBehaviors['authenticator'] = [
|
2016-05-30 02:44:17 +03:00
|
|
|
'class' => HttpBearerAuth::class,
|
2016-08-04 01:07:21 +03:00
|
|
|
'user' => Yii::$app->getUser(),
|
2016-02-24 01:15:04 +03:00
|
|
|
];
|
|
|
|
|
2019-07-15 01:59:56 +03:00
|
|
|
// XML and rate limiter is not necessary
|
2016-11-30 20:57:30 +03:00
|
|
|
unset(
|
|
|
|
$parentBehaviors['contentNegotiator']['formats']['application/xml'],
|
|
|
|
$parentBehaviors['rateLimiter']
|
|
|
|
);
|
2016-01-03 03:18:37 +03:00
|
|
|
|
|
|
|
return $parentBehaviors;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|