For example: items per specific category, comments by particular user etc.
This controller finds and creates models including possible filtering context.
findContextModel()
보호된 메소드
Initializes a particular active context.
protected findContextModel ( array $config, mixed $id ) : yii\db\ActiveRecordInterface | Model |
$config |
array |
context configuration. |
$id |
mixed |
context model primary key value. |
리턴 |
yii\db\ActiveRecordInterface | yii\base\Model |
context model instance. |
findContextModels()
보호된 메소드
Finds all active context models.
protected findContextModels ( ) : yii\db\ActiveRecordInterface[] | Model[] |
리턴 |
yii\db\ActiveRecordInterface[] | yii\base\Model[] |
active contexts. |
If 'null' name provided the first declared context will be returned.
If 'null' name provided the first active context model will be returned.
public getContextModel ( string | null $name = null ) : yii\db\ActiveRecordInterface | Model |
$name |
string | null |
context name. |
리턴 |
yii\db\ActiveRecordInterface | yii\base\Model |
default active context model. |
getContextModelUrl()
공개 메소드
Composes URL, which leads to the context model details page.
getContextModels()
공개 메소드
public getContextModels ( ) : yii\db\ActiveRecordInterface[] | Model[] |
리턴 |
yii\db\ActiveRecordInterface[] | yii\base\Model[] |
active context models |
getContextQueryParams()
공개 메소드
This method can be used to compose links.
Composes URL, which leads to the context model index page.
If 'null' name provided, checks if at least one context is active.
setContextModels()
공개 메소드
public setContextModels ( yii\db\ActiveRecordInterface[] | Model[] $contextModels ) |
$contextModels |
yii\db\ActiveRecordInterface[] | yii\base\Model[] |
active context models |
specifies possible contexts.
The array key is considered as context name, value - as context config.
Config should contain following keys:
- class: string, class name of context model.
- attribute: string, name of model attribute, which refers to the context model primary key.
- url: array|string, URL config or route to the controller, which manage context models.
- required: boolean, whether this context is mandatory for this controller or optional.
For example:
php
[
'user' => [
'class' => 'User',
'attribute' => 'userId',
'url' => 'user/view',
]
]