Contents

Backend\Behaviors\RelationController\HasNestedRelations

Overview

HasNestedRelations implements nested relation chains


Protected Properties

protected array $manageIds

manageIds provided by the relationship chain

protected array $sessionKeys

sessionKeys provided by the relationship chain


Protected Methods

protected getManageIdForField()

protected getManageIdForField($field): void

protected getSessionKeysForField()

protected getSessionKeysForField($field): array 

getSessionKeysForField returns a session key for saving a form and for binding a relation, the result is an array with [formSessionKey, relationSessionKey]

protected initNestedRelation()

protected initNestedRelation($model, $parentField): void

initNestedRelation checks the extra configuration for a relationship chain and binds the manage forms to the controller, which may contain additional relation definitions via the relation form widget.

protected makeNestedRelationModel()

protected makeNestedRelationModel($model, $field): void

makeNestedRelationModel resolves a relation based on a nested field name E.g: model[relation1][relation2] → $model->relation1()->relation2()

protected resolveNestedRelationModelFromDefault()

protected resolveNestedRelationModelFromDefault($model, $field): array 

protected resolveNestedRelationModelFromManageId()

protected resolveNestedRelationModelFromManageId($model, $field): array|null 

resolveNestedRelationModelFromManageId returns a resolved relation with a single hop

protected resolveNestedRelationModelFromModelRelationship()

protected resolveNestedRelationModelFromModelRelationship(
    $model,
    $field
): array|null 

resolveNestedRelationModelFromModelRelationship returns a nested relation model locating it using array_get to resolve the value