Class ekstazi\crud\actions\ModelFinder

Inheritanceekstazi\crud\actions\ModelFinder » yii\base\Model

Class ModelFinder Try to find record by its class name and params.

The typical usage of ModelFinder is as follows,

$finder=ModelFinder::create($modelClass);
if (!
$finder->load($params))
   throw new 
BadRequestHttpException($finder->getError());

if (!
$finder->exists())
   throw new 
NotFoundHttpException('The requested page does not exist.');

$model=$finder->model;

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$modelClass string Modelclass name ekstazi\crud\actions\ModelFinder
$params array Params from user ekstazi\crud\actions\ModelFinder

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$_model \yii\db\BaseActiveRecord Founded model ekstazi\crud\actions\ModelFinder
$_pk array Searched pk ekstazi\crud\actions\ModelFinder

Property Details

$_model protected property
\yii\db\BaseActiveRecord $_model null

Founded model

$_pk protected property
array $_pk null

Searched pk

$modelClass public property

Modelclass name

$params public property
array $params null

Params from user

Method Details

create() public method

Create finder instance

static create$modelClass )
$modelClass
getError() public method

Get error message

string getError( )
getModel() public method

Get founded model

\yii\db\BaseActiveRecord getModel( )
load() public method

Try to load params and validate

bool load$params = [] )
$params array
return bool

Whether the validation succeeds

rules() public method

array rules( )
validatePassed() public method

Validator for params

void validatePassed$attr$opts = [] )
$attr
$opts array