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
Exibir arquivo Open project: atk4/data

Public Properties

Property 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

Property 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.

Public Methods

Method 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 method

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

__debugInfo() public method

Returns array with useful debug info for var_dump.
public __debugInfo ( ) : array
return array

_init() public method

public _init ( )

getDesiredName() public method

Will use #ref_.
public getDesiredName ( ) : string
return string

getModel() public method

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

guessFieldType() public method

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
return string

init() public method

Initialization.
public init ( )

ref() public method

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
return Model

refModel() public method

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
return 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
return 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
return 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
return 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
return string