$findModel is NULL is DeleteAction

REST API DELETE Action has findModel=NULL (actually, all actions have this problem)

I cannot figure out why/how this came to be. Where does it normally get set?




    public function run($id)

    {

        \stewlog::crud('DELETE ACTION id=',$id);

/*

        [2018-03-10 09:51:58]

'DELETE ACTION THIS'

api\rest\DeleteAction#1

(

    [modelClass] => 'api\models\v1\faq\Faqdata'

    [findModel] => null                                 HERE IS A PROBLEM. WHY IS findModel NULL ?

    [checkAccess] => array

*/


        $model = $this->findModel($id);



I cannot find where this gets set "normally", so I am lost trying to debug it.

I had decided to copy the yii rest actions up to my own namespace and use them to learn/debug.

I had decided to create a BaseActiveController also in my own namespace. On principle.

Is that a bad idea? Is that why findModel is null? I cannot convince myself…


namespace api\controllers\v1;

...

class BaseActiveController extends ActiveController

{

    public function verbs()

    {

        return [

            'view' => ['GET', 'HEAD'],

            'create' => ['POST'],

            'update' => ['POST'],

            'delete' => ['DELETE'],

        ];


    }

    public function actions()

    {

        return [

...

            'delete' => [

                'class' => 'api\rest\DeleteAction',              

                'modelClass' => $this->modelClass,

                'checkAccess' => [$this, 'checkAccess'],

            ],

            'options' => [

                'class' => 'api\rest\OptionsAction',

            ],

        ];

    }

...



then


namespace api\controllers\v1\faq;

...

class FaqdataController extends BaseActiveController // dsm 29 feb

{

...

    protected function findModel($id)



// dsm 14 mar 18 : ok got it here http://www.yiiframework.com/forum/index.php/topic/70275-yii2-rest-api-create-action/

// https://stackoverflow.com/questions/27474059/yii-override-generic-rest-functions


// Also interesting: https://github.com/gustarus/yii2-rest




'findModel' => ['\path\to\your\callback', 'findModelByYourOwnMethod']


findModel' => [$this, 'findModel']