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. |
getContext()
публичный Метод
If 'null' name provided the first declared context will be returned.
getContextModel()
публичный Метод
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.
getContextUrl()
публичный Метод
Composes URL, which leads to the context model index page.
isContextActive()
публичный Метод
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 |
$contexts публичное свойство
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',
]
]