TYPO3  7.6
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
RelationHandler Class Reference

Public Member Functions

 getWorkspaceId ()
 
 setWorkspaceId ($workspaceId)
 
 isPurged ()
 
 start ($itemlist, $tablelist, $MMtable= '', $MMuid=0, $currentTable= '', $conf=array())
 
 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 = false
 
 $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.

Definition at line 28 of file RelationHandler.php.

Member Function Documentation

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 1303 of file RelationHandler.php.

References $GLOBALS, and elseif.

Referenced by RelationHandler\writeMM().

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.
Deprecated:
since TYPO3 CMS 7, will be removed in TYPO3 CMS 8

Definition at line 981 of file RelationHandler.php.

References MathUtility\canBeInterpretedAsInteger(), and GeneralUtility\logDeprecatedFunction().

countItems (   $returnAsArray = true)

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

Parameters
bool$returnAsArrayWhether to put the count value in an array
Returns
mixed The plain count as integer or the same inside an array

Definition at line 1073 of file RelationHandler.php.

getDatabaseConnection ( )
protected
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

Definition at line 1008 of file RelationHandler.php.

References $GLOBALS, and RelationHandler\$results.

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 1332 of file RelationHandler.php.

References BackendUtility\getLiveVersionIdOfRecord().

Referenced by RelationHandler\readForeignField(), RelationHandler\readList(), and RelationHandler\writeForeignField().

getValueArray (   $prependTableName = false)

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

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

Definition at line 954 of file RelationHandler.php.

getWorkspaceId ( )
static 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
bool Returns TRUE if looking from the symmetric ("other") side to the relation.

Definition at line 1288 of file RelationHandler.php.

References MathUtility\canBeInterpretedAsInteger().

isPurged ( )

Whether item array has been purged in this instance.

Returns
bool

Definition at line 244 of file RelationHandler.php.

References RelationHandler\$purged.

processDeletePlaceholder ( )

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

Returns
bool Whether items have been purged

Definition at line 1135 of file RelationHandler.php.

References RelationHandler\getWorkspaceId(), and RelationHandler\purgeItemArrayHandler().

purgeDeletePlaceholder (   $tableName,
array  $ids 
)
protected

Purges ids that have a delete placeholder

Parameters
string$tableName
array$ids
Returns
array

Definition at line 1245 of file RelationHandler.php.

References Enumeration\cast(), VersionState\DELETE_PLACEHOLDER, RelationHandler\getDatabaseConnection(), and RelationHandler\getWorkspaceId().

purgeItemArray (   $workspaceId = null)
Parameters
NULL | int$workspaceId
Returns
bool Whether items have been purged

Definition at line 1109 of file RelationHandler.php.

References RelationHandler\$workspaceId, RelationHandler\getWorkspaceId(), and RelationHandler\purgeItemArrayHandler().

Referenced by RelationHandler\start().

purgeItemArrayHandler (   $purgeCallback)
protected

Handles a purge callback on $this->itemArray

Parameters
callable$purgeCallback
Returns
bool Whether items have been purged

Definition at line 1150 of file RelationHandler.php.

References BackendUtility\isTableWorkspaceEnabled(), and RelationHandler\removeFromItemArray().

Referenced by RelationHandler\processDeletePlaceholder(), and RelationHandler\purgeItemArray().

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 1212 of file RelationHandler.php.

References RelationHandler\getDatabaseConnection().

purgeVersionedIds (   $tableName,
array  $ids 
)
protected

Purges ids that are versioned.

Parameters
string$tableName
array$ids
Returns
array

Definition at line 1180 of file RelationHandler.php.

References RelationHandler\getDatabaseConnection().

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
int$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

Definition at line 756 of file RelationHandler.php.

References $GLOBALS, RelationHandler\$undeleteRecord, BackendUtility\deleteClause(), elseif, RelationHandler\getLiveDefaultId(), RelationHandler\getWorkspaceId(), and BackendUtility\isTableWorkspaceEnabled().

Referenced by RelationHandler\start().

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

Definition at line 388 of file RelationHandler.php.

References RelationHandler\$firstTable, $GLOBALS, MathUtility\canBeInterpretedAsInteger(), RelationHandler\getLiveDefaultId(), BackendUtility\isTableWorkspaceEnabled(), and GeneralUtility\trimExplode().

Referenced by RelationHandler\start().

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
int$uidLocal UID
Returns
void

Definition at line 500 of file RelationHandler.php.

References RelationHandler\$additionalWhere, RelationHandler\$firstTable, $GLOBALS, RelationHandler\$MM_oppositeTable, and elseif.

Referenced by RelationHandler\start().

readyForInterface ( )

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

Returns
string

Definition at line 1048 of file RelationHandler.php.

References $GLOBALS, GeneralUtility\fixed_lgd_cs(), and BackendUtility\getRecordTitle().

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
int$uidLocal, current UID
int$newUidLocal, new UID
bool$prependTableNameIf set, then table names will always be written.
Returns
void

Definition at line 716 of file RelationHandler.php.

References RelationHandler\$additionalWhere, $GLOBALS, and RelationHandler\$MM_isMultiTableRelationship.

removeFromItemArray (   $tableName,
  $id 
)
protected

Definition at line 1269 of file RelationHandler.php.

Referenced by RelationHandler\purgeItemArrayHandler().

setFetchAllFields (   $allFields)

Sets $fetchAllFields

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

Definition at line 349 of file RelationHandler.php.

setUpdateReferenceIndex (   $updateReferenceIndex)

Sets whether the reference index shall be updated.

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

Definition at line 360 of file RelationHandler.php.

References RelationHandler\$updateReferenceIndex.

setUseLiveParentIds (   $useLiveParentIds)
Parameters
bool$useLiveParentIds

Definition at line 368 of file RelationHandler.php.

References RelationHandler\$useLiveParentIds.

setUseLiveReferenceIds (   $useLiveReferenceIds)
Parameters
bool$useLiveReferenceIds

Definition at line 376 of file RelationHandler.php.

References RelationHandler\$useLiveReferenceIds.

setWorkspaceId (   $workspaceId)

Sets the current workspace id.

Parameters
int$workspaceId

Definition at line 234 of file RelationHandler.php.

References RelationHandler\$workspaceId.

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

Definition at line 465 of file RelationHandler.php.

References $GLOBALS, and elseif.

Referenced by RelationHandler\start().

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.
int$MMuidLocal UID for MM lookup
string$currentTableCurrent table name
array$confTCA configuration for current field
Returns
void

Definition at line 260 of file RelationHandler.php.

References RelationHandler\$currentTable, $GLOBALS, RelationHandler\$MM_match_fields, RelationHandler\$MM_oppositeField, RelationHandler\$MM_oppositeTable, elseif, RelationHandler\purgeItemArray(), RelationHandler\readForeignField(), RelationHandler\readList(), RelationHandler\readMM(), RelationHandler\sortList(), and GeneralUtility\trimExplode().

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
int$parentUidThe uid of the parent record
int$updateToUidIf this is larger than zero it will be used as foreign UID instead of the given $parentUid (on Copy)
bool$skipSortingDo not update the sorting columns, this could happen for imported values
Returns
void

Definition at line 842 of file RelationHandler.php.

References RelationHandler\$currentTable, $GLOBALS, MathUtility\canBeInterpretedAsInteger(), Enumeration\cast(), elseif, RelationHandler\getLiveDefaultId(), BackendUtility\getRecord(), BackendUtility\isTableWorkspaceEnabled(), and VersionState\NEW_PLACEHOLDER_VERSION.

writeMM (   $MM_tableName,
  $uid,
  $prependTableName = false 
)

Writes the internal itemArray to MM table:

Parameters
string$MM_tableNameMM table name
int$uidLocal UID
bool$prependTableNameIf set, then table names will always be written.
Returns
void

Definition at line 563 of file RelationHandler.php.

References RelationHandler\$additionalWhere, RelationHandler\$currentTable, $GLOBALS, RelationHandler\$MM_insert_fields, and RelationHandler\completeOppositeUsageValues().

Member Data Documentation

$additionalWhere = array()
$checkIfDeleted = true

Definition at line 76 of file RelationHandler.php.

$currentTable
$dbPaths = array()

Definition at line 81 of file RelationHandler.php.

$fetchAllFields = false
protected

Definition at line 35 of file RelationHandler.php.

$firstTable = ''

Definition at line 88 of file RelationHandler.php.

Referenced by RelationHandler\readList(), and RelationHandler\readMM().

$itemArray = array()

Definition at line 57 of file RelationHandler.php.

$MM_hasUidField

Definition at line 161 of file RelationHandler.php.

$MM_insert_fields = array()

Definition at line 168 of file RelationHandler.php.

Referenced by RelationHandler\writeMM().

$MM_is_foreign = false

Definition at line 103 of file RelationHandler.php.

$MM_isMultiTableRelationship = ''

Definition at line 131 of file RelationHandler.php.

Referenced by RelationHandler\remapMM().

$MM_match_fields = array()

Definition at line 154 of file RelationHandler.php.

Referenced by RelationHandler\start().

$MM_oppositeField = ''

Definition at line 110 of file RelationHandler.php.

Referenced by RelationHandler\start().

$MM_oppositeFieldConf = ''

Definition at line 124 of file RelationHandler.php.

$MM_oppositeTable = ''

Definition at line 117 of file RelationHandler.php.

Referenced by RelationHandler\readMM(), and RelationHandler\start().

$MM_oppositeUsage
protected

Definition at line 182 of file RelationHandler.php.

$MM_table_where = ''

Definition at line 175 of file RelationHandler.php.

$nonTableArray = array()

Definition at line 64 of file RelationHandler.php.

$purged = false
protected

Definition at line 207 of file RelationHandler.php.

Referenced by RelationHandler\isPurged().

$registerNonTableValues = false

Definition at line 42 of file RelationHandler.php.

$results = array()

Definition at line 214 of file RelationHandler.php.

Referenced by RelationHandler\getFromDB().

$secondTable = ''

Definition at line 95 of file RelationHandler.php.

$tableArray = array()

Definition at line 50 of file RelationHandler.php.

$undeleteRecord

Definition at line 146 of file RelationHandler.php.

Referenced by RelationHandler\readForeignField().

$updateReferenceIndex = true
protected

Definition at line 187 of file RelationHandler.php.

Referenced by RelationHandler\setUpdateReferenceIndex().

$useLiveParentIds = true
protected

Definition at line 192 of file RelationHandler.php.

Referenced by RelationHandler\setUseLiveParentIds().

$useLiveReferenceIds = true
protected

Definition at line 197 of file RelationHandler.php.

Referenced by RelationHandler\setUseLiveReferenceIds().

$workspaceId
protected