PHP 클래스 yii2tech\admin\behaviors\ContextModelControlBehavior

For example: items per specific category, comments by particular user etc. This controller finds and creates models including possible filtering context.
또한 보기: ModelControlBehavior
부터: 1.0
저자: Paul Klimov ([email protected])
상속: extends ModelControlBehavior
파일 보기 프로젝트 열기: yii2tech/admin 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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', ] ]

공개 메소드들

메소드 설명
findModel ( $id )
getContext ( string | null $name = null ) : array Return context info by given name.
getContextModel ( string | null $name = null ) : yii\db\ActiveRecordInterface | Model Return active context model by given name.
getContextModelUrl ( string | null $name = null ) : array Composes URL, which leads to the context model details page.
getContextModels ( ) : yii\db\ActiveRecordInterface[] | Model[]
getContextQueryParams ( ) : array Returns query params for currently active contexts, like ['groupId' => 12].
getContextUrl ( string | null $name = null ) : array Composes URL, which leads to the context model index page.
isContextActive ( string | null $name = null ) : boolean Checks if named context is active (present in the query params).
newModel ( )
newSearchModel ( )
setContextModels ( yii\db\ActiveRecordInterface[] | Model[] $contextModels )

보호된 메소드들

메소드 설명
findContextModel ( array $config, mixed $id ) : yii\db\ActiveRecordInterface | Model Initializes a particular active context.
findContextModels ( ) : yii\db\ActiveRecordInterface[] | Model[] Finds all active context models.

메소드 상세

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.

findModel() 공개 메소드

public findModel ( $id )

getContext() 공개 메소드

If 'null' name provided the first declared context will be returned.
public getContext ( string | null $name = null ) : array
$name string | null context name.
리턴 array context config.

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.
public getContextModelUrl ( string | null $name = null ) : array
$name string | null context name.
리턴 array URL config.

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.
public getContextQueryParams ( ) : array
리턴 array query params.

getContextUrl() 공개 메소드

Composes URL, which leads to the context model index page.
public getContextUrl ( string | null $name = null ) : array
$name string | null context name.
리턴 array URL config.

isContextActive() 공개 메소드

If 'null' name provided, checks if at least one context is active.
public isContextActive ( string | null $name = null ) : boolean
$name string | null context name.
리턴 boolean whether context is active.

newModel() 공개 메소드

public newModel ( )

newSearchModel() 공개 메소드

public newSearchModel ( )

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', ] ]
public $contexts