PHP Class atk4\data\Reference

It's possible to extend the basic reference with more meaningful references.
Inheritance: use trait atk4\core\InitializerTrait, use trait atk4\core\TrackableTrait
Afficher le fichier Open project: atk4/data

Méthodes publiques

Свойство Type Description
$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 Properties

Свойство Type Description
$__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.

Méthodes publiques

Méthode Description
__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.

Method Details

__construct() public méthode

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

__debugInfo() public méthode

Returns array with useful debug info for var_dump.
public __debugInfo ( ) : array
Résultat array

_init() public méthode

public _init ( )

getDesiredName() public méthode

Will use #ref_.
public getDesiredName ( ) : string
Résultat string

getModel() public méthode

Returns destination model that is linked through this reference. Will apply necessary conditions.
public getModel ( array $defaults = [] ) : Model
$defaults array Properties
Résultat Model

guessFieldType() public méthode

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
Résultat string

init() public méthode

Initialization.
public init ( )

ref() public méthode

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
Résultat Model

refModel() public méthode

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
Résultat Model

Property Details

$__debug_fields protected_oe property

List of properties to show in var_dump.
protected $__debug_fields

$model public_oe property

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
Résultat Model | null

$our_field protected_oe property

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
Résultat string

$table_alias protected_oe property

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
Résultat string

$their_field protected_oe property

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
Résultat string