How to pass a variable from AccessFilter to Controller in Yii2 -


i have accessfilter class

class projectaccesscontrol extends \yii\base\actionfilter {    public $a;    /**     * @inheritdoc     */    public function beforeaction($action)    {         switch ($action->id) {           case 'view':              // code here              break;         }    } 

in controller revoke accessfilter in behaviour() method this:

public function behaviors() {     return [         'access' => [             'class' => projectaccesscontrol::classname(),         ]     ]; } 

now want pass $a variable accessfilter action in controller. how that?

you should add variable in controller, e.g. :

public $a; 

and use in filter :

$this->owner->a = $this->a; 

Comments