trait has_relations

Trait has_relations.

Provides runtime relation support for Domain models. Relations are runtime-only objects loaded by Repositories/Loaders (Lazy Load or Eager Load). They are not persisted directly to the item table.

Methods

mixed
__get(string $name)

Property-style access: $item->parent.

bool
__isset(string $name)

Check presence of a relation.

void
set_relation(string $name, mixed $value)

Set a relation value.

mixed
get_relation(string $name)

Public accessor for relations using snake_case.

bool
has_relation(string $name)

Returns TRUE if the relation was defined (even if value is null).

array
get_all_relations()

Get all currently loaded relations.

Details

at line 40
mixed __get(string $name)

Property-style access: $item->parent.

Convenience wrapper for get_relation().

Parameters

string $name

Return Value

mixed

at line 52
bool __isset(string $name)

Check presence of a relation.

Parameters

string $name

Return Value

bool

at line 72
void set_relation(string $name, mixed $value)

internal  
 

Set a relation value.

INTERNAL API used by loader and the query engine. Use Repository/Loader to set these during hydration.

Architecture Note: This mutates the internal state of the entity. In a strict immutable context, this might return a clone, but for hydration performance (lazy loading relations), direct mutation is acceptable here.

Parameters

string $name
mixed $value

Return Value

void

at line 84
mixed get_relation(string $name)

Public accessor for relations using snake_case.

Parameters

string $name

Return Value

mixed

at line 96
bool has_relation(string $name)

Returns TRUE if the relation was defined (even if value is null).

Parameters

string $name

Return Value

bool

at line 106
array get_all_relations()

Get all currently loaded relations.

Return Value

array