What am I missing? Why I don't need to specify this new action / router in verbs()
for GET
(I figured out that I must do this for other verbs)?
CodePudding user response:
In the referenced question/answer you were working with existing action index
that already had rule for yii\filters\VerbFilter
to only allow GET
or HEAD
verbs for that action.
But in case of completely new action test
there is no existing rule for VerbFilter
. If there is no rule for action the VerbFilter
will allow any request. That's why if you don't specify rule for test
action any verb set up in router will work. Once you specify the rule for test
in verbs()
method, only allowed verbs will make it through VerbFilter
.