Class ekstazi\crud\actions\ModelFinder
| Inheritance | ekstazi\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
| Property | Type | Description | Defined By |
|---|---|---|---|
| $modelClass | string | Modelclass name | ekstazi\crud\actions\ModelFinder |
| $params | array | Params from user | ekstazi\crud\actions\ModelFinder |
Protected Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| $_model | \yii\db\BaseActiveRecord | Founded model | ekstazi\crud\actions\ModelFinder |
| $_pk | array | Searched pk | ekstazi\crud\actions\ModelFinder |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| create() | Create finder instance | ekstazi\crud\actions\ModelFinder |
| getError() | Get error message | ekstazi\crud\actions\ModelFinder |
| getModel() | Get founded model | ekstazi\crud\actions\ModelFinder |
| load() | Try to load params and validate | ekstazi\crud\actions\ModelFinder |
| rules() | ekstazi\crud\actions\ModelFinder | |
| validatePassed() | Validator for params | ekstazi\crud\actions\ModelFinder |
Property Details
Founded model
Searched pk
Modelclass name
Params from user
Method Details
Create finder instance
| static create( $modelClass ) | ||
| $modelClass | ||
Get error message
| string getError( ) |
Get founded model
| \yii\db\BaseActiveRecord getModel( ) |
Try to load params and validate
| bool load( $params = [] ) | ||
| $params | array | |
| return | bool | Whether the validation succeeds |
|---|---|---|
| array rules( ) |
Validator for params
| void validatePassed( $attr, $opts = [] ) | ||
| $attr | ||
| $opts | array | |