Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace api\components;
- use yii\helpers\ArrayHelper;
- use yii\filters\Cors;
- use yii\filters\auth\HttpBearerAuth;
- trait ControllerTrait
- {
- /**
- * @return array
- */
- public function behaviors()
- {
- return $this->getBaseBehaviors();
- }
- /**
- * @return array
- */
- public function getBaseBehaviors()
- {
- $behaviors = ArrayHelper::merge(
- ['cors' => ['class' => Cors::class]],
- parent::behaviors(),
- ['authenticator' => ['class' => HttpBearerAuth::class]]
- );
- unset(
- $behaviors['contentNegotiator']['formats']['application/xml'],
- $behaviors['rateLimiter']
- );
- return $behaviors;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement