protected function initModel($id)
    {
        /* @var $model ActiveRecord */
        if ($id === null) {
            $model = new $this->modelClass(['scenario' => $this->createScenario]);
            $model->loadDefaultValues();
        } else {
            $model = $this->findModel($id);
            $model->scenario = $this->updateScenario;
        }

        if ($this->checkAccess) {
            // use only create and update auth item names because more actions are based on this one
            call_user_func($this->checkAccess, $id === null ? 'create' : 'update', $model);
        }
        return $model;
    }
protected function initModel($id)
    {
        /* @var $model ActiveRecord */
        if ($id === null) {
            $model = new $this->modelClass(['scenario' => $this->createScenario]);
            $model->loadDefaultValues();
        } else {
            $model = $this->findModel($id);
            $model->scenario = $this->updateScenario;
        }

        if ($this->checkAccess) {
            // use only create and update auth item names because more actions are based on this one
            call_user_func($this->checkAccess, $id === null ? 'create' : 'update', $model);
        }
        return $model;
    }
protected function initModel ( $ id ) { /* @var $model ActiveRecord */ if ( $ id === null ) { $ model = new $ this -> modelClass ( [ 'scenario' => $ this -> createScenario ] ) ; $ model -> loadDefaultValues ( ) ; } else { $ model = $ this -> findModel ( $ id ) ; $ model -> scenario = $ this -> updateScenario ; } if ( $ this -> checkAccess ) { // use only create and update auth item names because more actions are based on this one call_user_func ( $ this -> checkAccess , $ id === null ? 'create' : 'update' , $ model ) ; } return $ model ; }
Loads the model and performs authorization check.
@param string $id
@return ActiveRecord
@throws \yii\web\NotFoundHttpException
Loads the model and performs authorization check .