/**
  * Update relations on version/workspace swapping.
  *
  * @param string $table: Record Table
  * @param string $field: Record field
  * @param array $conf: TCA configuration of current field
  * @param array $curVersion: Reference to the current (original) record
  * @param array $swapVersion: Reference to the record (workspace/versionized) to publish in or swap with
  * @param t3lib_TCEmain $tcemainObj TCEmain object
  * @return  void
  */
 protected function version_swap_procBasedOnFieldType($table, $field, array $conf, array &$curVersion, array &$swapVersion, t3lib_TCEmain $tcemainObj)
 {
     $inlineType = $tcemainObj->getInlineFieldType($conf);
     // Process pointer fields on normalized database:
     if ($inlineType == 'field') {
         // Read relations that point to the current record (e.g. live record):
         /** @var $dbAnalysisCur t3lib_loadDBGroup */
         $dbAnalysisCur = t3lib_div::makeInstance('t3lib_loadDBGroup');
         $dbAnalysisCur->setUpdateReferenceIndex(FALSE);
         $dbAnalysisCur->start('', $conf['foreign_table'], '', $curVersion['uid'], $table, $conf);
         // Read relations that point to the record to be swapped with e.g. draft record):
         /** @var $dbAnalysisSwap t3lib_loadDBGroup */
         $dbAnalysisSwap = t3lib_div::makeInstance('t3lib_loadDBGroup');
         $dbAnalysisSwap->setUpdateReferenceIndex(FALSE);
         $dbAnalysisSwap->start('', $conf['foreign_table'], '', $swapVersion['uid'], $table, $conf);
         // Update relations for both (workspace/versioning) sites:
         if (count($dbAnalysisCur->itemArray)) {
             $dbAnalysisCur->writeForeignField($conf, $curVersion['uid'], $swapVersion['uid']);
             $tcemainObj->addRemapAction($table, $curVersion['uid'], array($this, 'writeRemappedForeignField'), array($dbAnalysisCur, $conf, $swapVersion['uid']));
         }
         if (count($dbAnalysisSwap->itemArray)) {
             $dbAnalysisSwap->writeForeignField($conf, $swapVersion['uid'], $curVersion['uid']);
             $tcemainObj->addRemapAction($table, $curVersion['uid'], array($this, 'writeRemappedForeignField'), array($dbAnalysisSwap, $conf, $curVersion['uid']));
         }
         $items = array_merge($dbAnalysisCur->itemArray, $dbAnalysisSwap->itemArray);
         foreach ($items as $item) {
             $tcemainObj->addRemapStackRefIndex($item['table'], $item['id']);
         }
         // Swap field values (CSV):
         // BUT: These values will be swapped back in the next steps, when the *CHILD RECORD ITSELF* is swapped!
     } elseif ($inlineType == 'list') {
         $tempValue = $curVersion[$field];
         $curVersion[$field] = $swapVersion[$field];
         $swapVersion[$field] = $tempValue;
     }
 }