PHP Класс atk4\data\Reference

It's possible to extend the basic reference with more meaningful references.
Наследование: use trait atk4\core\InitializerTrait, use trait atk4\core\TrackableTrait
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$model Model | null Definition of the destination model, that can be either an object, a callback or a string. This can be defined during initialization and then used inside getModel() to fully populate and associate with persistence.

Защищенные свойства (Protected)

Свойство Тип Описание
$__debug_fields List of properties to show in var_dump.
$link string Each reference has a unique identifier, although it's stored in Model's elements as '#ref-xx'.
$our_field string This is an optional property which can be used by your implementation to store field-level relationship based on a common field matching.
$table_alias string Use this alias for related entity by default. This can help you if you create sub-queries or joins to separate this from main table. The table_alias will be uniquelly generated.
$their_field string This is an optional property which can be used by your implementation to store field-level relationship based on a common field matching.

Открытые методы

Метод Описание
__construct ( array $defaults = [] ) Default constructor. Will copy argument into properties.
__debugInfo ( ) : array Returns array with useful debug info for var_dump.
_init ( )
getDesiredName ( ) : string Will use #ref_.
getModel ( array $defaults = [] ) : Model Returns destination model that is linked through this reference. Will apply necessary conditions.
guessFieldType ( string $their_field = null ) : string If you have set $their_field property correctly, then calling this method will traverse into a related model and fetch the type of their field. This method will be extra careful to avoid any loops.
init ( ) Initialization.
ref ( array $defaults = [] ) : Model Returns referenced model without any extra conditions. However other relationship types may override this to imply conditions.
refModel ( array $defaults = [] ) : Model Returns referenced model without any extra conditions. Ever when extended must always respond with Model that does not look into current record or scope.

Описание методов

__construct() публичный Метод

Default constructor. Will copy argument into properties.
public __construct ( array $defaults = [] )
$defaults array

__debugInfo() публичный Метод

Returns array with useful debug info for var_dump.
public __debugInfo ( ) : array
Результат array

_init() публичный Метод

public _init ( )

getDesiredName() публичный Метод

Will use #ref_.
public getDesiredName ( ) : string
Результат string

getModel() публичный Метод

Returns destination model that is linked through this reference. Will apply necessary conditions.
public getModel ( array $defaults = [] ) : Model
$defaults array Properties
Результат Model

guessFieldType() публичный Метод

If you have set $their_field property correctly, then calling this method will traverse into a related model and fetch the type of their field. This method will be extra careful to avoid any loops.
public guessFieldType ( string $their_field = null ) : string
$their_field string
Результат string

init() публичный Метод

Initialization.
public init ( )

ref() публичный Метод

Returns referenced model without any extra conditions. However other relationship types may override this to imply conditions.
public ref ( array $defaults = [] ) : Model
$defaults array Properties
Результат Model

refModel() публичный Метод

Returns referenced model without any extra conditions. Ever when extended must always respond with Model that does not look into current record or scope.
public refModel ( array $defaults = [] ) : Model
$defaults array Properties
Результат Model

Описание свойств

$__debug_fields защищенное свойство

List of properties to show in var_dump.
protected $__debug_fields

$model публичное свойство

Definition of the destination model, that can be either an object, a callback or a string. This can be defined during initialization and then used inside getModel() to fully populate and associate with persistence.
public Model,atk4\data|null $model
Результат Model | null

$our_field защищенное свойство

This is an optional property which can be used by your implementation to store field-level relationship based on a common field matching.
protected string $our_field
Результат string

$table_alias защищенное свойство

Use this alias for related entity by default. This can help you if you create sub-queries or joins to separate this from main table. The table_alias will be uniquelly generated.
protected string $table_alias
Результат string

$their_field защищенное свойство

This is an optional property which can be used by your implementation to store field-level relationship based on a common field matching.
protected string $their_field
Результат string