Joomla CMS  3.10.11 (avec JPlatform 13.1 inclus)
Documentation des API du CMS Joomla en version 3.10.11 et du framework Joomla Platform intégré
Tout Structures de données Espaces de nommage Fichiers Fonctions Variables Pages
Référence de la classe FOFTableRelations

Fonctions membres publiques

 __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)
 

Fonctions membres protégées

 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)
 

Attributs protégés

 $relations
 
 $defaultRelation
 
 $table = null
 
 $componentName = 'joomla'
 
 $tableType = ''
 

Documentation des constructeurs et destructeur

◆ __construct()

__construct ( FOFTable  $table)

Create a relations object based on the provided FOFTable instance

Paramètres
FOFTable$tableThe 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().

Documentation des fonctions membres

◆ addBespokePivotRelation()

addBespokePivotRelation (   $relationType,
  $itemName,
  $tableClass,
  $localKey,
  $remoteKey,
  $ourPivotKey,
  $theirPivotKey,
  $pivotTable,
  $default 
)
protected

Add any bespoke relation which involves a pivot table.

Paramètres
string$relationTypeThe type of the relationship (multiple)
string$itemNameis how it will be known locally to the getRelatedItems method
string$tableClassif skipped it is defined automatically as ComponentnameTableItemname
string$localKeyis the column containing our side of the FK relation, default: componentname_itemname_id
string$remoteKeyis the remote table's FK column, default: componentname_itemname_id
string$ourPivotKeyis the column containing our side of the FK relation in the pivot table, default: $localKey
string$theirPivotKeyis the column containing the other table's side of the FK relation in the pivot table, default $remoteKey
string$pivotTableis the name of the glue (pivot) table, default: #__componentname_thisclassname_itemname with plural items (e.g. #__foobar_users_roles)
boolean$defaultis 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$relationTypeThe type of the relationship (parent, child, children)
string$itemNameis how it will be known locally to the getRelatedItems method
string$tableClassif skipped it is defined automatically as ComponentnameTableItemname
string$localKeyis the column containing our side of the FK relation, default: componentname_itemname_id
string$remoteKeyis the remote table's FK column, default: componentname_itemname_id
boolean$defaultis 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$itemNameis how it will be known locally to the getRelatedItem method (singular)
string$tableClassif skipped it is defined automatically as ComponentnameTableItemname
string$localKeyis the column containing our side of the FK relation, default: our primary key
string$remoteKeyis the remote table's FK column, default: componentname_itemname_id
boolean$defaultadd 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$itemNameis how it will be known locally to the getRelatedItems method (plural)
string$tableClassif skipped it is defined automatically as ComponentnameTableItemname
string$localKeyis the column containing our side of the FK relation, default: our primary key
string$remoteKeyis the remote table's FK column, default: componentname_itemname_id
boolean$defaultis 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$itemNameis how it will be known locally to the getRelatedItems method (plural)
string$tableClassif skipped it is defined automatically as ComponentnameTableItemname
string$localKeyis the column containing our side of the FK relation, default: our primary key field name
string$ourPivotKeyis the column containing our side of the FK relation in the pivot table, default: $localKey
string$theirPivotKeyis the column containing the other table's side of the FK relation in the pivot table, default $remoteKey
string$remoteKeyis the remote table's FK column, default: componentname_itemname_id
string$glueTableis the name of the glue (pivot) table, default: #__componentname_thisclassname_itemname with plural items (e.g. #__foobar_users_roles)
boolean$defaultis 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$itemNameis how it will be known locally to the getRelatedItem method (singular)
string$tableClassif skipped it is defined automatically as ComponentnameTableItemname
string$localKeyis the column containing our side of the FK relation, default: componentname_itemname_id
string$remoteKeyis the remote table's FK column, default: componentname_itemname_id
boolean$defaultIs this the default parent relationship?
Renvoie
void

Références $default.

◆ clearRelations()

clearRelations (   $type = null)

Removes all existing relations

Paramètres
string$typeThe 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
RuntimeExceptionWhen 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
RuntimeExceptionWhen the relation is not found

◆ getIteratorFromRelation()

getIteratorFromRelation (   $relation)
protected

Returns a FOFDatabaseIterator based on a given relation

Paramètres
array$relationIndexed array holding relation definition. tableClass => name of the related table class localKey => name of the local key remoteKey => name of the remote key pivotTable => name of the pivot table (optional) theirPivotKey => name of the remote key in the pivot table (mandatory if pivotTable is set) ourPivotKey => name of our key in the pivot table (mandatory if pivotTable is set)
Renvoie
FOFDatabaseIterator
Exceptions
RuntimeException
InvalidArgumentException

Références $db, $query, $value, FOFInflector\explode(), FOFTable\getInstance(), FOFDatabaseIterator\getIterator(), et null.

◆ 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
RuntimeExceptionWhen 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
RuntimeExceptionWhen 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$itemNameThe name of the relation to use
string$type[optional] The relation type (child, parent)
Renvoie
FOFTable
Exceptions
RuntimeExceptionIf 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$itemNameThe name of the relation to use
string$type[optional] The relation type (children, multiple)
Renvoie
FOFDatabaseIterator
Exceptions
RuntimeExceptionIf 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$itemNameThe name of the relation to check
string$type[optional] The relation type (child, parent, children, ...)
Renvoie
array
Exceptions
RuntimeExceptionWhen 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
RuntimeExceptionWhen the relation is not found

Références FOFInflector\singularize().

◆ getTableFromRelation()

getTableFromRelation (   $relation)
protected

Returns a FOFTable object based on a given relation

Paramètres
array$relationIndexed array holding relation definition. tableClass => name of the related table class localKey => name of the local key remoteKey => name of the remote key
Renvoie
FOFTable
Exceptions
RuntimeException
InvalidArgumentException

Références $data, $db, $query, $value, FOFInflector\explode(), et FOFTable\getInstance().

◆ hasRelation()

hasRelation (   $itemName,
  $type = null 
)

Does the named relation exist? You can optionally specify the type.

Paramètres
string$itemNameThe 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

Normalises the format of a relation name

Paramètres
string$itemNameThe raw relation name
boolean$pluraliseShould I pluralise the name? If not, I will singularise it
Renvoie
string The normalised relation key name

Références $name, $prefix, FOFInflector\implode(), null, FOFInflector\pluralize(), et FOFInflector\singularize().

◆ normaliseParameters()

normaliseParameters (   $pivot,
$itemName,
$tableClass,
$localKey,
$remoteKey,
$ourPivotKey,
$theirPivotKey,
$pivotTable 
)
protected

Normalise the parameters of a relation, guessing missing values

Paramètres
boolean$pivotIs this a many to many relation involving a pivot table?
string$itemNameis how it will be known locally to the getRelatedItems method (plural)
string$tableClassif skipped it is defined automatically as ComponentnameTableItemname
string$localKeyis the column containing our side of the FK relation, default: componentname_itemname_id
string$remoteKeyis the remote table's FK column, default: componentname_itemname_id
string$ourPivotKeyis the column containing our side of the FK relation in the pivot table, default: $localKey
string$theirPivotKeyis the column containing the other table's side of the FK relation in the pivot table, default $remoteKey
string$pivotTableis 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$itemNameThe name of the relation to remove
string$type[optional] The relation type (child, parent, children, ...)
Renvoie
void

Références $key, $type, et null.

Documentation des champs

◆ $componentName

$componentName = 'joomla'
protected

◆ $defaultRelation

$defaultRelation
protected
Valeur initiale :
= array(
'child' => null,
'parent' => null,
'children' => null,
'multiple' => null,
)

◆ $relations

$relations
protected
Valeur initiale :
= array(
'child' => array(),
'parent' => array(),
'children' => array(),
'multiple' => array(),
)

◆ $table

$table = null
protected

◆ $tableType

$tableType = ''
protected

La documentation de cette classe a été générée à partir du fichier suivant :