TYPO3 CMS  TYPO3_6-2
TYPO3\CMS\Core\Database\RelationHandler Class Reference
Inheritance diagram for TYPO3\CMS\Core\Database\RelationHandler:
FE_loadDBGroup t3lib_loadDBGroup

Public Member Functions

 getWorkspaceId ()
 
 setWorkspaceId ($workspaceId)
 
 isPurged ()
 
 start ($itemlist, $tablelist, $MMtable='', $MMuid=0, $currentTable='', $conf=array())
 
 __set ($name, $value)
 
 setFetchAllFields ($allFields)
 
 setUpdateReferenceIndex ($updateReferenceIndex)
 
 setUseLiveParentIds ($useLiveParentIds)
 
 setUseLiveReferenceIds ($useLiveReferenceIds)
 
 readList ($itemlist, array $configuration)
 
 sortList ($sortby)
 
 readMM ($tableName, $uid)
 
 writeMM ($MM_tableName, $uid, $prependTableName=FALSE)
 
 remapMM ($MM_tableName, $uid, $newUid, $prependTableName=FALSE)
 
 readForeignField ($uid, $conf)
 
 writeForeignField ($conf, $parentUid, $updateToUid=0, $skipSorting=FALSE)
 
 getValueArray ($prependTableName=FALSE)
 
 convertPosNeg ($valueArray, $fTable, $nfTable)
 
 getFromDB ()
 
 readyForInterface ()
 
 countItems ($returnAsArray=TRUE)
 
 purgeItemArray ($workspaceId=NULL)
 
 processDeletePlaceholder ()
 

Static Public Member Functions

static isOnSymmetricSide ($parentUid, $parentConf, $childRec)
 

Public Attributes

 $registerNonTableValues = 0
 
 $tableArray = array()
 
 $itemArray = array()
 
 $nonTableArray = array()
 
 $additionalWhere = array()
 
 $checkIfDeleted = TRUE
 
 $dbPaths = array()
 
 $firstTable = ''
 
 $secondTable = ''
 
 $MM_is_foreign = FALSE
 
 $MM_oppositeField = ''
 
 $MM_oppositeTable = ''
 
 $MM_oppositeFieldConf = ''
 
 $MM_isMultiTableRelationship = ''
 
 $currentTable
 
 $undeleteRecord
 
 $MM_match_fields = array()
 
 $MM_hasUidField
 
 $MM_insert_fields = array()
 
 $MM_table_where = ''
 
 $results = array()
 

Protected Member Functions

 purgeItemArrayHandler ($purgeCallback)
 
 purgeVersionedIds ($tableName, array $ids)
 
 purgeLiveVersionedIds ($tableName, array $ids)
 
 purgeDeletePlaceholder ($tableName, array $ids)
 
 removeFromItemArray ($tableName, $id)
 
 completeOppositeUsageValues ($tableName, array $referenceValues)
 
 getLiveDefaultId ($tableName, $id)
 
 getDatabaseConnection ()
 

Protected Attributes

 $fetchAllFields = FALSE
 
 $MM_oppositeUsage
 
 $updateReferenceIndex = TRUE
 
 $useLiveParentIds = TRUE
 
 $useLiveReferenceIds = TRUE
 
 $workspaceId
 
 $purged = FALSE
 

Detailed Description

Load database groups (relations) Used to process the relations created by the TCA element types "group" and "select" for database records. Manages MM-relations as well.

Author
Kasper Skårhøj kaspe.nosp@m.rYYY.nosp@m.Y@typ.nosp@m.o3.c.nosp@m.om

Definition at line 30 of file RelationHandler.php.

Member Function Documentation

◆ __set()

TYPO3\CMS\Core\Database\RelationHandler::__set (   $name,
  $value 
)

Magic setter method. Used for compatibility with changed attribute visibility

Parameters
string$namename of the attribute
mixed$valuevalue to set the attribute to
Deprecated:
since 6.1, only required as compatibility layer for renamed attribute $fromTC

Definition at line 369 of file RelationHandler.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\deprecationLog(), and TYPO3\CMS\Core\Database\RelationHandler\setFetchAllFields().

◆ completeOppositeUsageValues()

TYPO3\CMS\Core\Database\RelationHandler::completeOppositeUsageValues (   $tableName,
array  $referenceValues 
)
protected

Completes MM values to be written by values from the opposite relation. This method used MM insert field or MM match fields if defined.

Parameters
string$tableNameName of the opposite table
array$referenceValuesValues to be written
Returns
array Values to be written, possibly modified

Definition at line 1324 of file RelationHandler.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Core\Database\RelationHandler\writeMM().

◆ convertPosNeg()

TYPO3\CMS\Core\Database\RelationHandler::convertPosNeg (   $valueArray,
  $fTable,
  $nfTable 
)

Converts id numbers from negative to positive.

Parameters
array$valueArrayArray of [table]_[id] pairs.
string$fTableForeign table (the one used for positive numbers)
string$nfTableNegative foreign table
Returns
array The array with ID integer values, converted to positive for those where the table name was set but did NOT match the positive foreign table.
Todo:
Define visibility

Definition at line 1011 of file RelationHandler.php.

References TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger().

◆ countItems()

TYPO3\CMS\Core\Database\RelationHandler::countItems (   $returnAsArray = TRUE)

Counts the items in $this->itemArray and puts this value in an array by default.

Parameters
boolean$returnAsArrayWhether to put the count value in an array
Returns
mixed The plain count as integer or the same inside an array
Todo:
Define visibility

Definition at line 1102 of file RelationHandler.php.

References TYPO3\CMS\Core\Database\RelationHandler\getWorkspaceId(), TYPO3\CMS\Backend\Utility\BackendUtility\isTableWorkspaceEnabled(), and TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

◆ getDatabaseConnection()

◆ getFromDB()

TYPO3\CMS\Core\Database\RelationHandler::getFromDB ( )

Reads all records from internal tableArray into the internal ->results array where keys are table names and for each table, records are stored with uids as their keys. If $this->fetchAllFields is false you can save a little memory since only uid,pid and a few other fields are selected.

Returns
array
Todo:
Define visibility

Definition at line 1037 of file RelationHandler.php.

References $GLOBALS, and TYPO3\CMS\Core\Database\RelationHandler\$results.

◆ getLiveDefaultId()

TYPO3\CMS\Core\Database\RelationHandler::getLiveDefaultId (   $tableName,
  $id 
)
protected

Gets the record uid of the live default record. If already pointing to the live record, the submitted record uid is returned.

Parameters
string$tableName
int$id
Returns
int

Definition at line 1352 of file RelationHandler.php.

References TYPO3\CMS\Backend\Utility\BackendUtility\getLiveVersionIdOfRecord(), TYPO3\CMS\Core\Database\RelationHandler\getWorkspaceId(), and TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

Referenced by TYPO3\CMS\Core\Database\RelationHandler\readForeignField(), TYPO3\CMS\Core\Database\RelationHandler\readList(), and TYPO3\CMS\Core\Database\RelationHandler\writeForeignField().

◆ getValueArray()

TYPO3\CMS\Core\Database\RelationHandler::getValueArray (   $prependTableName = FALSE)

After initialization you can extract an array of the elements from the object. Use this function for that.

Parameters
boolean$prependTableNameIf set, then table names will ALWAYS be prepended (unless its a _NO_TABLE value)
Returns
array A numeric array.
Todo:
Define visibility

Definition at line 985 of file RelationHandler.php.

◆ getWorkspaceId()

◆ isOnSymmetricSide()

static TYPO3\CMS\Core\Database\RelationHandler::isOnSymmetricSide (   $parentUid,
  $parentConf,
  $childRec 
)
static

Checks, if we're looking from the "other" side, the symmetric side, to a symmetric relation.

Parameters
string$parentUidThe uid of the parent record
array$parentConfThe TCA configuration of the parent field embedding the child records
array$childRecThe record row of the child record
Returns
boolean Returns TRUE if looking from the symmetric ("other") side to the relation.
Todo:
Define visibility

Definition at line 1310 of file RelationHandler.php.

References TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger().

Referenced by TYPO3\CMS\Backend\Form\Element\InlineElement\renderForeignRecordHeader(), TYPO3\CMS\Backend\Form\Element\InlineElement\renderForeignRecordHeaderControl(), and TYPO3\CMS\Backend\Form\Element\InlineElement\skipField().

◆ isPurged()

TYPO3\CMS\Core\Database\RelationHandler::isPurged ( )

Whether item array has been purged in this instance.

Returns
bool

Definition at line 262 of file RelationHandler.php.

References TYPO3\CMS\Core\Database\RelationHandler\$purged.

◆ processDeletePlaceholder()

TYPO3\CMS\Core\Database\RelationHandler::processDeletePlaceholder ( )

Removes items having a delete placeholder from $this->itemArray

Returns
bool Whether items have been purged

Definition at line 1162 of file RelationHandler.php.

References TYPO3\CMS\Core\Database\RelationHandler\getWorkspaceId(), and TYPO3\CMS\Core\Database\RelationHandler\purgeItemArrayHandler().

◆ purgeDeletePlaceholder()

TYPO3\CMS\Core\Database\RelationHandler::purgeDeletePlaceholder (   $tableName,
array  $ids 
)
protected

◆ purgeItemArray()

TYPO3\CMS\Core\Database\RelationHandler::purgeItemArray (   $workspaceId = NULL)

◆ purgeItemArrayHandler()

TYPO3\CMS\Core\Database\RelationHandler::purgeItemArrayHandler (   $purgeCallback)
protected

Handles a purge callback on $this->itemArray

Parameters
callable$purgeCallback
Returns
bool Whether items have been purged

Definition at line 1176 of file RelationHandler.php.

References TYPO3\CMS\Backend\Utility\BackendUtility\isTableWorkspaceEnabled(), and TYPO3\CMS\Core\Database\RelationHandler\removeFromItemArray().

Referenced by TYPO3\CMS\Core\Database\RelationHandler\processDeletePlaceholder(), and TYPO3\CMS\Core\Database\RelationHandler\purgeItemArray().

◆ purgeLiveVersionedIds()

TYPO3\CMS\Core\Database\RelationHandler::purgeLiveVersionedIds (   $tableName,
array  $ids 
)
protected

Purges ids that are live but have an accordant version.

Parameters
string$tableName
array$ids
Returns
array

Definition at line 1236 of file RelationHandler.php.

References TYPO3\CMS\Core\Database\RelationHandler\getDatabaseConnection().

◆ purgeVersionedIds()

TYPO3\CMS\Core\Database\RelationHandler::purgeVersionedIds (   $tableName,
array  $ids 
)
protected

Purges ids that are versioned.

Parameters
string$tableName
array$ids
Returns
array

Definition at line 1205 of file RelationHandler.php.

References TYPO3\CMS\Core\Database\RelationHandler\getDatabaseConnection().

◆ readForeignField()

TYPO3\CMS\Core\Database\RelationHandler::readForeignField (   $uid,
  $conf 
)

Reads items from a foreign_table, that has a foreign_field (uid of the parent record) and stores the parts in the internal array itemArray and tableArray.

Parameters
integer$uidThe uid of the parent record (this value is also on the foreign_table in the foreign_field)
array$confTCA configuration for current field
Returns
void
Todo:
Define visibility

Definition at line 787 of file RelationHandler.php.

References $GLOBALS, $uid, TYPO3\CMS\Core\Database\RelationHandler\$undeleteRecord, TYPO3\CMS\Backend\Utility\BackendUtility\deleteClause(), TYPO3\CMS\Core\Database\RelationHandler\getLiveDefaultId(), TYPO3\CMS\Core\Database\RelationHandler\getWorkspaceId(), and TYPO3\CMS\Backend\Utility\BackendUtility\isTableWorkspaceEnabled().

Referenced by TYPO3\CMS\Core\Database\RelationHandler\start().

◆ readList()

TYPO3\CMS\Core\Database\RelationHandler::readList (   $itemlist,
array  $configuration 
)

Explodes the item list and stores the parts in the internal arrays itemArray and tableArray from MM records.

Parameters
string$itemlistItem list
array$configurationParent field configuration
Returns
void
Todo:
Define visibility

Definition at line 419 of file RelationHandler.php.

References TYPO3\CMS\Core\Database\RelationHandler\$firstTable, $GLOBALS, TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger(), TYPO3\CMS\Core\Database\RelationHandler\getLiveDefaultId(), TYPO3\CMS\Backend\Utility\BackendUtility\isTableWorkspaceEnabled(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

Referenced by TYPO3\CMS\Core\Database\RelationHandler\start().

◆ readMM()

TYPO3\CMS\Core\Database\RelationHandler::readMM (   $tableName,
  $uid 
)

Reads the record tablename/id into the internal arrays itemArray and tableArray from MM records. You can call this function after start if you supply no list to start()

Parameters
string$tableNameMM Tablename
integer$uidLocal UID
Returns
void
Todo:
Define visibility

Definition at line 531 of file RelationHandler.php.

References TYPO3\CMS\Core\Database\RelationHandler\$additionalWhere, TYPO3\CMS\Core\Database\RelationHandler\$firstTable, $GLOBALS, TYPO3\CMS\Core\Database\RelationHandler\$MM_oppositeTable, and $uid.

Referenced by TYPO3\CMS\Core\Database\RelationHandler\start().

◆ readyForInterface()

TYPO3\CMS\Core\Database\RelationHandler::readyForInterface ( )

Prepare items from itemArray to be transferred to the TCEforms interface (as a comma list)

Returns
string
Todo:
Define visibility

Definition at line 1077 of file RelationHandler.php.

References $GLOBALS, TYPO3\CMS\Core\Utility\GeneralUtility\fixed_lgd_cs(), and TYPO3\CMS\Backend\Utility\BackendUtility\getRecordTitle().

◆ remapMM()

TYPO3\CMS\Core\Database\RelationHandler::remapMM (   $MM_tableName,
  $uid,
  $newUid,
  $prependTableName = FALSE 
)

Remaps MM table elements from one local uid to another Does NOT update the reference index for you, must be called subsequently to do that!

Parameters
string$MM_tableNameMM table name
integer$uidLocal, current UID
integer$newUidLocal, new UID
boolean$prependTableNameIf set, then table names will always be written.
Returns
void
Todo:
Define visibility

Definition at line 747 of file RelationHandler.php.

References TYPO3\CMS\Core\Database\RelationHandler\$additionalWhere, $GLOBALS, TYPO3\CMS\Core\Database\RelationHandler\$MM_isMultiTableRelationship, and $uid.

◆ removeFromItemArray()

TYPO3\CMS\Core\Database\RelationHandler::removeFromItemArray (   $tableName,
  $id 
)
protected

◆ setFetchAllFields()

TYPO3\CMS\Core\Database\RelationHandler::setFetchAllFields (   $allFields)

Sets $fetchAllFields

Parameters
boolean$allFieldsenables fetching of all fields in getFromDB()

Definition at line 383 of file RelationHandler.php.

Referenced by TYPO3\CMS\Core\Database\RelationHandler\__set().

◆ setUpdateReferenceIndex()

TYPO3\CMS\Core\Database\RelationHandler::setUpdateReferenceIndex (   $updateReferenceIndex)

Sets whether the reference index shall be updated.

Parameters
boolean$updateReferenceIndexWhether the reference index shall be updated
Returns
void

Definition at line 393 of file RelationHandler.php.

References TYPO3\CMS\Core\Database\RelationHandler\$updateReferenceIndex.

◆ setUseLiveParentIds()

TYPO3\CMS\Core\Database\RelationHandler::setUseLiveParentIds (   $useLiveParentIds)
Parameters
bool$useLiveParentIds

Definition at line 400 of file RelationHandler.php.

References TYPO3\CMS\Core\Database\RelationHandler\$useLiveParentIds.

◆ setUseLiveReferenceIds()

TYPO3\CMS\Core\Database\RelationHandler::setUseLiveReferenceIds (   $useLiveReferenceIds)
Parameters
bool$useLiveReferenceIds

Definition at line 407 of file RelationHandler.php.

References TYPO3\CMS\Core\Database\RelationHandler\$useLiveReferenceIds.

◆ setWorkspaceId()

TYPO3\CMS\Core\Database\RelationHandler::setWorkspaceId (   $workspaceId)

Sets the current workspace id.

Parameters
int$workspaceId

Definition at line 253 of file RelationHandler.php.

References TYPO3\CMS\Core\Database\RelationHandler\$workspaceId.

◆ sortList()

TYPO3\CMS\Core\Database\RelationHandler::sortList (   $sortby)

Does a sorting on $this->itemArray depending on a default sortby field. This is only used for automatic sorting of comma separated lists. This function is only relevant for data that is stored in comma separated lists!

Parameters
string$sortbyThe default_sortby field/command (e.g. 'price DESC')
Returns
void
Todo:
Define visibility

Definition at line 496 of file RelationHandler.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Core\Database\RelationHandler\start().

◆ start()

TYPO3\CMS\Core\Database\RelationHandler::start (   $itemlist,
  $tablelist,
  $MMtable = '',
  $MMuid = 0,
  $currentTable = '',
  $conf = array() 
)

Initialization of the class.

Parameters
string$itemlistList of group/select items
string$tablelistComma list of tables, first table takes priority if no table is set for an entry in the list.
string$MMtableName of a MM table.
integer$MMuidLocal UID for MM lookup
string$currentTableCurrent table name
array$confTCA configuration for current field
Returns
void
Todo:
Define visibility

Definition at line 278 of file RelationHandler.php.

References TYPO3\CMS\Core\Database\RelationHandler\$currentTable, $GLOBALS, TYPO3\CMS\Core\Database\RelationHandler\$MM_match_fields, TYPO3\CMS\Core\Database\RelationHandler\$MM_oppositeField, TYPO3\CMS\Core\Database\RelationHandler\$MM_oppositeTable, TYPO3\CMS\Core\Database\RelationHandler\purgeItemArray(), TYPO3\CMS\Core\Database\RelationHandler\readForeignField(), TYPO3\CMS\Core\Database\RelationHandler\readList(), TYPO3\CMS\Core\Database\RelationHandler\readMM(), TYPO3\CMS\Core\Database\RelationHandler\sortList(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

◆ writeForeignField()

TYPO3\CMS\Core\Database\RelationHandler::writeForeignField (   $conf,
  $parentUid,
  $updateToUid = 0,
  $skipSorting = FALSE 
)

Write the sorting values to a foreign_table, that has a foreign_field (uid of the parent record)

Parameters
array$confTCA configuration for current field
integer$parentUidThe uid of the parent record
integer$updateToUidIf this is larger than zero it will be used as foreign UID instead of the given $parentUid (on Copy)
boolean$skipSortingDo not update the sorting columns, this could happen for imported values
Returns
void
Todo:
Define visibility

Definition at line 873 of file RelationHandler.php.

References TYPO3\CMS\Core\Database\RelationHandler\$currentTable, $GLOBALS, $uid, TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger(), TYPO3\CMS\Core\Type\Enumeration\cast(), TYPO3\CMS\Core\Database\RelationHandler\getLiveDefaultId(), TYPO3\CMS\Backend\Utility\BackendUtility\isTableWorkspaceEnabled(), and TYPO3\CMS\Core\Versioning\VersionState\NEW_PLACEHOLDER_VERSION.

◆ writeMM()

TYPO3\CMS\Core\Database\RelationHandler::writeMM (   $MM_tableName,
  $uid,
  $prependTableName = FALSE 
)

Writes the internal itemArray to MM table:

Parameters
string$MM_tableNameMM table name
integer$uidLocal UID
boolean$prependTableNameIf set, then table names will always be written.
Returns
void
Todo:
Define visibility

Definition at line 594 of file RelationHandler.php.

References TYPO3\CMS\Core\Database\RelationHandler\$additionalWhere, TYPO3\CMS\Core\Database\RelationHandler\$currentTable, $GLOBALS, TYPO3\CMS\Core\Database\RelationHandler\$MM_insert_fields, $uid, and TYPO3\CMS\Core\Database\RelationHandler\completeOppositeUsageValues().

Member Data Documentation

◆ $additionalWhere

TYPO3\CMS\Core\Database\RelationHandler::$additionalWhere = array()

◆ $checkIfDeleted

TYPO3\CMS\Core\Database\RelationHandler::$checkIfDeleted = TRUE

Definition at line 82 of file RelationHandler.php.

◆ $currentTable

◆ $dbPaths

TYPO3\CMS\Core\Database\RelationHandler::$dbPaths = array()

Definition at line 88 of file RelationHandler.php.

◆ $fetchAllFields

TYPO3\CMS\Core\Database\RelationHandler::$fetchAllFields = FALSE
protected

Definition at line 37 of file RelationHandler.php.

◆ $firstTable

TYPO3\CMS\Core\Database\RelationHandler::$firstTable = ''

◆ $itemArray

TYPO3\CMS\Core\Database\RelationHandler::$itemArray = array()

Definition at line 60 of file RelationHandler.php.

◆ $MM_hasUidField

TYPO3\CMS\Core\Database\RelationHandler::$MM_hasUidField

Definition at line 179 of file RelationHandler.php.

◆ $MM_insert_fields

TYPO3\CMS\Core\Database\RelationHandler::$MM_insert_fields = array()

◆ $MM_is_foreign

TYPO3\CMS\Core\Database\RelationHandler::$MM_is_foreign = FALSE

Definition at line 113 of file RelationHandler.php.

◆ $MM_isMultiTableRelationship

TYPO3\CMS\Core\Database\RelationHandler::$MM_isMultiTableRelationship = ''

◆ $MM_match_fields

TYPO3\CMS\Core\Database\RelationHandler::$MM_match_fields = array()

Definition at line 171 of file RelationHandler.php.

Referenced by TYPO3\CMS\Core\Database\RelationHandler\start().

◆ $MM_oppositeField

TYPO3\CMS\Core\Database\RelationHandler::$MM_oppositeField = ''

Definition at line 121 of file RelationHandler.php.

Referenced by TYPO3\CMS\Core\Database\RelationHandler\start().

◆ $MM_oppositeFieldConf

TYPO3\CMS\Core\Database\RelationHandler::$MM_oppositeFieldConf = ''

Definition at line 137 of file RelationHandler.php.

◆ $MM_oppositeTable

TYPO3\CMS\Core\Database\RelationHandler::$MM_oppositeTable = ''

◆ $MM_oppositeUsage

TYPO3\CMS\Core\Database\RelationHandler::$MM_oppositeUsage
protected

Definition at line 202 of file RelationHandler.php.

◆ $MM_table_where

TYPO3\CMS\Core\Database\RelationHandler::$MM_table_where = ''

Definition at line 195 of file RelationHandler.php.

◆ $nonTableArray

TYPO3\CMS\Core\Database\RelationHandler::$nonTableArray = array()

Definition at line 68 of file RelationHandler.php.

◆ $purged

TYPO3\CMS\Core\Database\RelationHandler::$purged = FALSE
protected

◆ $registerNonTableValues

TYPO3\CMS\Core\Database\RelationHandler::$registerNonTableValues = 0

If set, values that are not ids in tables are normally discarded. By this options they will be preserved.

Todo:
Define visibility

Definition at line 43 of file RelationHandler.php.

◆ $results

TYPO3\CMS\Core\Database\RelationHandler::$results = array()

◆ $secondTable

TYPO3\CMS\Core\Database\RelationHandler::$secondTable = ''

Definition at line 104 of file RelationHandler.php.

◆ $tableArray

TYPO3\CMS\Core\Database\RelationHandler::$tableArray = array()

Definition at line 52 of file RelationHandler.php.

◆ $undeleteRecord

TYPO3\CMS\Core\Database\RelationHandler::$undeleteRecord

◆ $updateReferenceIndex

TYPO3\CMS\Core\Database\RelationHandler::$updateReferenceIndex = TRUE
protected

◆ $useLiveParentIds

TYPO3\CMS\Core\Database\RelationHandler::$useLiveParentIds = TRUE
protected

◆ $useLiveReferenceIds

TYPO3\CMS\Core\Database\RelationHandler::$useLiveReferenceIds = TRUE
protected

◆ $workspaceId