I have created a standard yii\rest\ActiveController
and added my custom action to it:
public function actionTest($id)
{
return ['test' => $id];
}
I have added a new entry to extraPatterns
of rules
of yii\web\UrlManager
:
'extraPatterns' => [
'GET test/{id}' => 'test',
],
Following this answer, I have also added new verb definition in my REST controller:
public function verbs()
{
$verbs = parent::verbs();
$verbs['test'] = ['GET'];
return $verbs;
}
But it turned out to be not needed. Meaning that I can comment out the above piece of code (the entire method in this case) and the whole new REST route is still working:
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)?