How to pass variable from AccessFilter to controller in Yii2
I have an AccessFilter class
class ProjectAccessControl extends \yii\base\ActionFilter
{
public $a;
/**
* @inheritdoc
*/
public function beforeAction($action)
{
switch ($action->id) {
case 'view':
// code here
break;
}
}
In the controller, I override this AccessFilter method in behavior () like this:
public function behaviors()
{
return [
'access' => [
'class' => ProjectAccessControl::className(),
]
];
}
Now I want to pass a variable $a
from AccessFilter to any action in the controller. How to do it?
+3
source to share