Property | Type | Description | |
---|---|---|---|
$eager | A list of the names of eager loaded relations | ||
$parentModel | The data model we are attached to | ||
$relationTypes | The known relation types | ||
$relations | The relations known to us |
Method | Description | |
---|---|---|
__call ( string $name, array $arguments ) : |
A magic method which allows us to define relations using shorthand notation, e.g. $manager->hasOne('phone') instead of $manager->addRelation('phone', 'hasOne') | |
__clone ( ) | Implements deep cloning of the relation object | |
__construct ( |
Creates a new relation manager for the defined parent model | |
__get ( $name ) : |
Magic method to get the data of a relation using shorthand notation, e.g. $manager->phone instead of $manager->getData('phone') | |
addRelation ( string $name, string $type, string $foreignModelName = null, string $localKey = null, string $foreignKey = null, string $pivotTable = null, string $pivotLocalKey = null, string $pivotForeignKey = null ) : |
Adds a relation to the relation manager | |
getCountSubquery ( string $name, string $tableAlias = null ) : JDatabaseQuery | Returns the count sub-query for a relation, used for relation filters (whereHas in the DataModel). | |
getData ( string $name, callable $callback = null, |
Gets the related items of a relation | |
getForeignKeyMap ( string $name ) : array | Gets the foreign key map of a many-to-many relation | |
getNew ( string $name ) : |
Get a new related item which satisfies relation $name and adds it to this relation's data list. | |
getRelation ( string $name ) : |
Gets the related items of a relation | |
getRelationNames ( ) : array | Returns a list of all known relations' names | |
getRelationTypes ( ) : array | Populates the static map of relation type methods and relation handling classes | |
isMagicMethod ( string $name ) : boolean | Is $name a magic-callable method? | |
isMagicProperty ( string $name ) : boolean | Is $name a magic property? Corollary: returns true if a relation of this name is known to the relation manager. | |
rebase ( |
Rebase a relation manager | |
removeRelation ( string $name ) : |
Removes a known relation | |
resetRelationData ( array $relationsToReset = [] ) | Resets the data of all relations in this manager. This doesn't remove relations, just their data so that they get loaded again. | |
resetRelations ( ) | Removes all known relations | |
save ( null | string $name = null ) : |
Saves all related items belonging to the specified relation or, if $name is null, all known relations which support saving. | |
setDataFromCollection ( string $name, |
Populates the internal $this->data collection of a relation from the contents of the provided collection. This is used by DataModel to push the eager loaded data into each item's relation. |
public __construct ( |
||
$parentModel | The model we are attached to |
public __get ( $name ) : |
||
$name | ||
return |
public addRelation ( string $name, string $type, string $foreignModelName = null, string $localKey = null, string $foreignKey = null, string $pivotTable = null, string $pivotLocalKey = null, string $pivotForeignKey = null ) : |
||
$name | string | The name of the relation as known to this relation manager, e.g. 'phone' |
$type | string | The relation type, e.g. 'hasOne' |
$foreignModelName | string | The name of the foreign key's model in the format "modelName@com_something" |
$localKey | string | The local table key for this relation |
$foreignKey | string | The foreign key for this relation |
$pivotTable | string | For many-to-many relations, the pivot (glue) table |
$pivotLocalKey | string | For many-to-many relations, the pivot table's column storing the local key |
$pivotForeignKey | string | For many-to-many relations, the pivot table's column storing the foreign key |
return | The parent model, for chaining |
public getCountSubquery ( string $name, string $tableAlias = null ) : JDatabaseQuery | ||
$name | string | The relation to get the sub-query for |
$tableAlias | string | The alias to use for the local table |
return | JDatabaseQuery |
public getData ( string $name, callable $callback = null, |
||
$name | string | The name of the relation to return data for |
$callback | callable | A callback to customise the returned data |
$dataCollection | Used when fetching the data of an eager loaded relation | |
return |
public getForeignKeyMap ( string $name ) : array | ||
$name | string | The name of the relation to return data for |
return | array |
public getRelation ( string $name ) : |
||
$name | string | The name of the relation to return data for |
return |
public getRelationNames ( ) : array | ||
return | array |
public static getRelationTypes ( ) : array | ||
return | array | Key = method name, Value = relation handling class |
public isMagicMethod ( string $name ) : boolean | ||
$name | string | The name of a potential magic-callable method |
return | boolean |
public isMagicProperty ( string $name ) : boolean | ||
$name | string | The name of a potential magic property |
return | boolean |
public rebase ( |
||
$parentModel |
public removeRelation ( string $name ) : |
||
$name | string | The name of the relation to remove |
return | The parent model, for chaining |
public resetRelationData ( array $relationsToReset = [] ) | ||
$relationsToReset | array | The names of the relations to reset. Pass an empty array (default) to reset all relations. |
protected static $relationTypes |