Hi, I’m using the tools that comes with Yii2 to create a REST Service but I need more resources that the ones that come by default (list/insert/etc). I’m overriding the current ones and it is working this way:
class TestController extends ActiveController
{
public $modelClass = 'app\models\Test';
public function actions()
{
$actions = parent::actions();
unset($actions['index']);
return $actions;
}
public function actionIndex()
{
//code
}
}
Could someone please tell me if I am doing the overwrite in the right way ? And how can I create new actions for the REST service?
I’m using the extraPatterns to define the route to the new action that is defined on the controller:
class TestController extends ActiveController
{
public $modelClass = 'app\models\Test';
public function actions()
{
$actions = parent::actions();
unset($actions['index']);
return $actions;
}
public function actionIndex()
{
//code
}
public function actionCustom()
{
//code
}
}
With this code, when I call the index action the application recognizes it and return the action that is defined on that controller. But when I call the custom action I always get a 404 error.
Is my routing well configured? There is a lot of documentation on the definitive guide for the RESTful services but not regarding this topic of creating different actions for the API