actionParams are not available in ACF’s matchCallback

When using matchCallback in AccessControlFilter in Yii2, an attempt to read $action->controller->actionParams or Yii::$app->controller->actionParams inside this callback fails, because these attributes are empty.

This is by design, because AccessControlFilter is executed at an earlier stage than parameters binding.

If you need to read action parameters inside matchCallback (for example to judge, if user has access to particular action, basing on action’s parameters) then the only way is to read them from Yii::$app->request->get(). More details here or here.

Leave a Reply