Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. <?php
  2.  
  3. namespace api\components;
  4.  
  5. use yii\helpers\ArrayHelper;
  6. use yii\filters\Cors;
  7. use yii\filters\auth\HttpBearerAuth;
  8.  
  9. trait ControllerTrait
  10. {
  11.     /**
  12.      * @return array
  13.      */
  14.     public function behaviors()
  15.     {
  16.         return $this->getBaseBehaviors();
  17.     }
  18.  
  19.     /**
  20.      * @return array
  21.      */
  22.     public function getBaseBehaviors()
  23.     {
  24.         $behaviors = ArrayHelper::merge(
  25.             ['cors' => ['class' => Cors::class]],
  26.             parent::behaviors(),
  27.             ['authenticator' => ['class' => HttpBearerAuth::class]]
  28.         );
  29.  
  30.         unset(
  31.             $behaviors['contentNegotiator']['formats']['application/xml'],
  32.             $behaviors['rateLimiter']
  33.         );
  34.  
  35.         return $behaviors;
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement