2016-01-03 05:48:37 +05:30
|
|
|
<?php
|
2019-07-15 04:29:56 +05:30
|
|
|
declare(strict_types=1);
|
|
|
|
|
2016-01-03 05:48:37 +05:30
|
|
|
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
|
|
|
/**
|
2019-07-15 04:29:56 +05:30
|
|
|
* Behaviors:
|
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();
|
2019-07-15 04:29:56 +05:30
|
|
|
// Add JWT authenticator
|
2016-02-24 03:45:04 +05:30
|
|
|
$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
|
|
|
];
|
|
|
|
|
2019-07-15 04:29:56 +05:30
|
|
|
// XML and rate limiter is not necessary
|
2016-11-30 23:27:30 +05:30
|
|
|
unset(
|
|
|
|
$parentBehaviors['contentNegotiator']['formats']['application/xml'],
|
|
|
|
$parentBehaviors['rateLimiter']
|
|
|
|
);
|
2016-01-03 05:48:37 +05:30
|
|
|
|
|
|
|
return $parentBehaviors;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|