Yii2 Override generic create Action in Rest ActiveController

后端 未结 3 811
半阙折子戏
半阙折子戏 2020-12-10 02:30

I have a Rest API in Yii2, and Yii generates all actions

view / update / create / delete

I want to change the comportement of createMethode et garde the othe

3条回答
  •  有刺的猬
    2020-12-10 02:57

    Or you can do by following this step :

    public function actions() {
        $actions = parent::actions();
        // will overriding return data on the index action
        $actions['index']['prepareDataProvider'] = [new app/models/Post(), 'getAllPost'];
        return $actions;
    }
    

提交回复
热议问题