title: use both beforeAction() and behaviors() method in controller in Yii2
body: <p>I want to use both <code>beforeAction()</code> and <code>behaviors()</code> method in my controller.</p>
  
  <p>If i add <code>beforeAction()</code> method in my code than <code>behaviors()</code> method is not working.</p>
  
  <p>And if i remove  <code>beforeAction()</code> method than <code>behaviors()</code> method is working.</p>
  
  <p>I dont want to remove <code>beforeAction()</code> as it is use to disable csrf  token for ajax calls.</p>
  
  <pre><code>public function beforeAction($action)
  {
    if($action-&gt;id =='ignore' || $action-&gt;id =='accept')
    {
      $this-&gt;enableCsrfValidation = false;
    }
    return true;
  }
  </code></pre>
  
  <p>And i want to use <code>behaviors()</code> method for authentication.</p>
  
  <pre><code>public function behaviors()
  {
      return [
          'access' =&gt; [
              'class' =&gt; AccessControl::className(),
              'only' =&gt; ['create','index','update','change','view','page','active','list'],
              'rules' =&gt; [
                  [
                      'actions' =&gt; ['create','index','update','change','view','page','active','list'],
                      'allow' =&gt; true,
                      'roles' =&gt; ['@'],
                      'matchCallback' =&gt; function ($rule, $action)
                      {
                        echo "string";
                        die;
                      },
                  ],
              ],
              'denyCallback' =&gt; function ($rule, $action) {
                  return $this-&gt;redirect(Yii::$app-&gt;request-&gt;baseUrl);
              }
          ],
      ];
  }
  </code></pre>
  
  <p>Is there any way to use both method in same controller.</p>