|
| | __construct (FOFTable $table) |
| |
| | addChildRelation ($itemName, $tableClass=null, $localKey=null, $remoteKey=null, $default=true) |
| |
| | addParentRelation ($itemName, $tableClass=null, $localKey=null, $remoteKey=null, $default=true) |
| |
| | addChildrenRelation ($itemName, $tableClass=null, $localKey=null, $remoteKey=null, $default=true) |
| |
| | addMultipleRelation ($itemName, $tableClass=null, $localKey=null, $ourPivotKey=null, $theirPivotKey=null, $remoteKey=null, $glueTable=null, $default=true) |
| |
| | removeRelation ($itemName, $type=null) |
| |
| | clearRelations ($type=null) |
| |
| | hasRelation ($itemName, $type=null) |
| |
| | getRelation ($itemName, $type) |
| |
| | getRelatedItem ($itemName, $type=null) |
| |
| | getRelatedItems ($itemName, $type=null) |
| |
| | getParent ($itemName=null) |
| |
| | getChild ($itemName=null) |
| |
| | getChildren ($itemName=null) |
| |
| | getSiblings ($itemName=null) |
| |
| | getMultiple ($itemName=null) |
| |
|
| | getTableFromRelation ($relation) |
| |
| | getIteratorFromRelation ($relation) |
| |
| | addBespokeSimpleRelation ($relationType, $itemName, $tableClass, $localKey, $remoteKey, $default) |
| |
| | addBespokePivotRelation ($relationType, $itemName, $tableClass, $localKey, $remoteKey, $ourPivotKey, $theirPivotKey, $pivotTable, $default) |
| |
| | normaliseParameters ($pivot, &$itemName, &$tableClass, &$localKey, &$remoteKey, &$ourPivotKey, &$theirPivotKey, &$pivotTable) |
| |
| | normaliseItemName ($itemName, $pluralise=false) |
| |
◆ __construct()
Create a relations object based on the provided FOFTable instance
- Paramètres
-
| FOFTable | $table | The table instance used to initialise the relations |
Références $default, $field, $key, $parts, $type, FOFTable\getConfigProvider(), FOFTable\getConfigProviderKey(), FOFTable\getKeyName(), FOFTable\getKnownFields(), FOFTable\getTableName(), et FOFInflector\singularize().
◆ addBespokePivotRelation()
| addBespokePivotRelation |
( |
|
$relationType, |
|
|
|
$itemName, |
|
|
|
$tableClass, |
|
|
|
$localKey, |
|
|
|
$remoteKey, |
|
|
|
$ourPivotKey, |
|
|
|
$theirPivotKey, |
|
|
|
$pivotTable, |
|
|
|
$default |
|
) |
| |
|
protected |
Add any bespoke relation which involves a pivot table.
- Paramètres
-
| string | $relationType | The type of the relationship (multiple) |
| string | $itemName | is how it will be known locally to the getRelatedItems method |
| string | $tableClass | if skipped it is defined automatically as ComponentnameTableItemname |
| string | $localKey | is the column containing our side of the FK relation, default: componentname_itemname_id |
| string | $remoteKey | is the remote table's FK column, default: componentname_itemname_id |
| string | $ourPivotKey | is the column containing our side of the FK relation in the pivot table, default: $localKey |
| string | $theirPivotKey | is the column containing the other table's side of the FK relation in the pivot table, default $remoteKey |
| string | $pivotTable | is the name of the glue (pivot) table, default: #__componentname_thisclassname_itemname with plural items (e.g. #__foobar_users_roles) |
| boolean | $default | is this the default children relationship? |
- Renvoie
- void
Références $default.
◆ addBespokeSimpleRelation()
| addBespokeSimpleRelation |
( |
|
$relationType, |
|
|
|
$itemName, |
|
|
|
$tableClass, |
|
|
|
$localKey, |
|
|
|
$remoteKey, |
|
|
|
$default |
|
) |
| |
|
protected |
Add any bespoke relation which doesn't involve a pivot table.
- Paramètres
-
| string | $relationType | The type of the relationship (parent, child, children) |
| string | $itemName | is how it will be known locally to the getRelatedItems method |
| string | $tableClass | if skipped it is defined automatically as ComponentnameTableItemname |
| string | $localKey | is the column containing our side of the FK relation, default: componentname_itemname_id |
| string | $remoteKey | is the remote table's FK column, default: componentname_itemname_id |
| boolean | $default | is this the default children relationship? |
- Renvoie
- void
Références $default, et null.
◆ addChildRelation()
| addChildRelation |
( |
|
$itemName, |
|
|
|
$tableClass = null, |
|
|
|
$localKey = null, |
|
|
|
$remoteKey = null, |
|
|
|
$default = true |
|
) |
| |
Add a 1:1 forward (child) relation. This adds relations for the getChild() method.
In other words: does a table HAVE ONE child
Parent and child relations works the same way. We have them separated as it makes more sense for us humans to read code like $item->getParent() and $item->getChild() than $item->getRelatedObject('someRandomKeyName')
- Paramètres
-
| string | $itemName | is how it will be known locally to the getRelatedItem method (singular) |
| string | $tableClass | if skipped it is defined automatically as ComponentnameTableItemname |
| string | $localKey | is the column containing our side of the FK relation, default: our primary key |
| string | $remoteKey | is the remote table's FK column, default: componentname_itemname_id |
| boolean | $default | add as the default child relation? |
- Renvoie
- void
Références $default.
◆ addChildrenRelation()
| addChildrenRelation |
( |
|
$itemName, |
|
|
|
$tableClass = null, |
|
|
|
$localKey = null, |
|
|
|
$remoteKey = null, |
|
|
|
$default = true |
|
) |
| |
Defining a forward 1:∞ (children) relation. This adds relations to the getChildren() method.
In other words: does a table HAVE MANY children?
The children relation works very much the same as the parent and child relation. The difference is that the parent and child relations return a single table object, whereas the children relation returns an iterator to many objects.
- Paramètres
-
| string | $itemName | is how it will be known locally to the getRelatedItems method (plural) |
| string | $tableClass | if skipped it is defined automatically as ComponentnameTableItemname |
| string | $localKey | is the column containing our side of the FK relation, default: our primary key |
| string | $remoteKey | is the remote table's FK column, default: componentname_itemname_id |
| boolean | $default | is this the default children relationship? |
- Renvoie
- void
Références $default.
◆ addMultipleRelation()
| addMultipleRelation |
( |
|
$itemName, |
|
|
|
$tableClass = null, |
|
|
|
$localKey = null, |
|
|
|
$ourPivotKey = null, |
|
|
|
$theirPivotKey = null, |
|
|
|
$remoteKey = null, |
|
|
|
$glueTable = null, |
|
|
|
$default = true |
|
) |
| |
Defining a ∞:∞ (multiple) relation. This adds relations to the getMultiple() method.
In other words: is a table RELATED TO MANY other records?
- Paramètres
-
| string | $itemName | is how it will be known locally to the getRelatedItems method (plural) |
| string | $tableClass | if skipped it is defined automatically as ComponentnameTableItemname |
| string | $localKey | is the column containing our side of the FK relation, default: our primary key field name |
| string | $ourPivotKey | is the column containing our side of the FK relation in the pivot table, default: $localKey |
| string | $theirPivotKey | is the column containing the other table's side of the FK relation in the pivot table, default $remoteKey |
| string | $remoteKey | is the remote table's FK column, default: componentname_itemname_id |
| string | $glueTable | is the name of the glue (pivot) table, default: #__componentname_thisclassname_itemname with plural items (e.g. #__foobar_users_roles) |
| boolean | $default | is this the default multiple relation? |
Références $default.
◆ addParentRelation()
| addParentRelation |
( |
|
$itemName, |
|
|
|
$tableClass = null, |
|
|
|
$localKey = null, |
|
|
|
$remoteKey = null, |
|
|
|
$default = true |
|
) |
| |
Defining an inverse 1:1 (parent) relation. You must specify at least the $tableClass or the $localKey. This adds relations for the getParent() method.
In other words: does a table BELONG TO ONE parent
Parent and child relations works the same way. We have them separated as it makes more sense for us humans to read code like $item->getParent() and $item->getChild() than $item->getRelatedObject('someRandomKeyName')
- Paramètres
-
| string | $itemName | is how it will be known locally to the getRelatedItem method (singular) |
| string | $tableClass | if skipped it is defined automatically as ComponentnameTableItemname |
| string | $localKey | is the column containing our side of the FK relation, default: componentname_itemname_id |
| string | $remoteKey | is the remote table's FK column, default: componentname_itemname_id |
| boolean | $default | Is this the default parent relationship? |
- Renvoie
- void
Références $default.
◆ clearRelations()
| clearRelations |
( |
|
$type = null | ) |
|
Removes all existing relations
- Paramètres
-
| string | $type | The type or relations to remove, omit to remove all relation types |
- Renvoie
- void
Références $type, et null.
◆ getChild()
| getChild |
( |
|
$itemName = null | ) |
|
Gets a child item
- Paramètres
-
| string | $itemName | [optional] The name of the relation to use, skip to use the default child relation |
- Renvoie
- FOFTable
- Exceptions
-
| RuntimeException | When the relation is not found |
◆ getChildren()
| getChildren |
( |
|
$itemName = null | ) |
|
Gets an iterator for the children items
- Paramètres
-
| string | $itemName | [optional] The name of the relation to use, skip to use the default children relation |
- Renvoie
- FOFDatabaseIterator
- Exceptions
-
| RuntimeException | When the relation is not found |
◆ getIteratorFromRelation()
| getIteratorFromRelation |
( |
|
$relation | ) |
|
|
protected |
◆ getMultiple()
| getMultiple |
( |
|
$itemName = null | ) |
|
Gets an iterator for the multiple items
- Paramètres
-
| string | $itemName | [optional] The name of the relation to use, skip to use the default multiple relation |
- Renvoie
- FOFDatabaseIterator
- Exceptions
-
| RuntimeException | When the relation is not found |
◆ getParent()
| getParent |
( |
|
$itemName = null | ) |
|
Gets a parent item
- Paramètres
-
| string | $itemName | [optional] The name of the relation to use, skip to use the default parent relation |
- Renvoie
- FOFTable
- Exceptions
-
| RuntimeException | When the relation is not found |
◆ getRelatedItem()
| getRelatedItem |
( |
|
$itemName, |
|
|
|
$type = null |
|
) |
| |
Gets the item referenced by a named relation. You can optionally specify the type. Only single item relation types will be searched.
- Paramètres
-
| string | $itemName | The name of the relation to use |
| string | $type | [optional] The relation type (child, parent) |
- Renvoie
- FOFTable
- Exceptions
-
| RuntimeException | If the named relation doesn't exist or isn't supposed to return single items |
Références $type.
◆ getRelatedItems()
| getRelatedItems |
( |
|
$itemName, |
|
|
|
$type = null |
|
) |
| |
Gets the iterator for the items referenced by a named relation. You can optionally specify the type. Only multiple item relation types will be searched.
- Paramètres
-
| string | $itemName | The name of the relation to use |
| string | $type | [optional] The relation type (children, multiple) |
- Renvoie
- FOFDatabaseIterator
- Exceptions
-
| RuntimeException | If the named relation doesn't exist or isn't supposed to return single items |
Références $type.
◆ getRelation()
| getRelation |
( |
|
$itemName, |
|
|
|
$type |
|
) |
| |
Get the definition of a relation
- Paramètres
-
| string | $itemName | The name of the relation to check |
| string | $type | [optional] The relation type (child, parent, children, ...) |
- Renvoie
- array
- Exceptions
-
| RuntimeException | When the relation is not found |
Références $key, et $type.
◆ getSiblings()
| getSiblings |
( |
|
$itemName = null | ) |
|
Gets an iterator for the sibling items. This relation is inferred from the parent relation. It returns all elements on the same table which have the same parent.
- Paramètres
-
| string | $itemName | [optional] The name of the relation to use, skip to use the default children relation |
- Renvoie
- FOFDatabaseIterator
- Exceptions
-
| RuntimeException | When the relation is not found |
Références FOFInflector\singularize().
◆ getTableFromRelation()
| getTableFromRelation |
( |
|
$relation | ) |
|
|
protected |
◆ hasRelation()
| hasRelation |
( |
|
$itemName, |
|
|
|
$type = null |
|
) |
| |
Does the named relation exist? You can optionally specify the type.
- Paramètres
-
| string | $itemName | The name of the relation to check |
| string | $type | [optional] The relation type (child, parent, children, ...) |
- Renvoie
- boolean
Références $key, et $type.
◆ normaliseItemName()
| normaliseItemName |
( |
|
$itemName, |
|
|
|
$pluralise = false |
|
) |
| |
|
protected |
◆ normaliseParameters()
| normaliseParameters |
( |
|
$pivot, |
|
|
& |
$itemName, |
|
|
& |
$tableClass, |
|
|
& |
$localKey, |
|
|
& |
$remoteKey, |
|
|
& |
$ourPivotKey, |
|
|
& |
$theirPivotKey, |
|
|
& |
$pivotTable |
|
) |
| |
|
protected |
Normalise the parameters of a relation, guessing missing values
- Paramètres
-
| boolean | $pivot | Is this a many to many relation involving a pivot table? |
| string | $itemName | is how it will be known locally to the getRelatedItems method (plural) |
| string | $tableClass | if skipped it is defined automatically as ComponentnameTableItemname |
| string | $localKey | is the column containing our side of the FK relation, default: componentname_itemname_id |
| string | $remoteKey | is the remote table's FK column, default: componentname_itemname_id |
| string | $ourPivotKey | is the column containing our side of the FK relation in the pivot table, default: $localKey |
| string | $theirPivotKey | is the column containing the other table's side of the FK relation in the pivot table, default $remoteKey |
| string | $pivotTable | is the name of the glue (pivot) table, default: #__componentname_thisclassname_itemname with plural items (e.g. #__foobar_users_roles) |
- Renvoie
- void
Références elseif, FOFInflector\explode(), null, FOFInflector\pluralize(), et FOFInflector\singularize().
◆ removeRelation()
| removeRelation |
( |
|
$itemName, |
|
|
|
$type = null |
|
) |
| |
Removes a previously defined relation by name. You can optionally specify the relation type.
- Paramètres
-
| string | $itemName | The name of the relation to remove |
| string | $type | [optional] The relation type (child, parent, children, ...) |
- Renvoie
- void
Références $key, $type, et null.
◆ $componentName
| $componentName = 'joomla' |
|
protected |
◆ $defaultRelation
◆ $relations
Valeur initiale := array(
'child' => array(),
'parent' => array(),
'children' => array(),
'multiple' => array(),
)
◆ $table
◆ $tableType
La documentation de cette classe a été générée à partir du fichier suivant :