/**
  * @param array $row
  * @param integer $uid
  * @return void
  */
 protected function updateRecordInDatabase(array $row, $uid = NULL)
 {
     if (NULL === $uid) {
         $uid = $row['uid'];
     }
     $uid = (int) $uid;
     if (FALSE === empty($uid)) {
         $row['uid'] = $uid;
         $this->workspacesAwareRecordService->update('tt_content', $row);
         // reload our record for the next bits to have access to all fields
         $row = $this->recordService->getSingle('tt_content', '*', $uid);
     }
     $versionedRecordUid = (int) (TRUE === isset($row['t3ver_oid']) && 0 < (int) $row['t3ver_oid'] ? $row['t3ver_oid'] : 0);
     if (0 < $versionedRecordUid) {
         // temporary record; duplicate key values of original record into temporary one.
         // Note: will continue to call this method until all temporary records in chain have been processed.
         $placeholder = $this->recordService->getSingle('tt_content', '*', $row['t3ver_oid']);
         $placeholder['tx_flux_parent'] = (int) $row['tx_flux_parent'];
         $placeholder['tx_flux_column'] = $row['tx_flux_column'];
         $this->updateRecordInDatabase($placeholder, $row['t3ver_oid']);
     }
 }
Beispiel #2
0
 /**
  * Post-process record data for the table that this ConfigurationProvider
  * is attached to.
  *
  * @param string $operation TYPO3 operation identifier, i.e. "update", "new" etc.
  * @param integer $id The ID of the current record (which is sometimes now included in $row
  * @param array $row the record data, by reference. Changing fields' values changes the record's values just before saving
  * @param DataHandler $reference A reference to the \TYPO3\CMS\Core\DataHandling\DataHandler object that is currently saving the record
  * @param array $removals Allows overridden methods to pass an additional array of field names to remove from the stored Flux value
  * @return void
  */
 public function postProcessRecord($operation, $id, array &$row, DataHandler $reference, array $removals = array())
 {
     if ('update' === $operation) {
         $record = $reference->datamap[$this->tableName][$id];
         $stored = $this->recordService->getSingle($this->tableName, '*', $record['uid']);
         $fieldName = $this->getFieldName((array) $record);
         $dontProcess = NULL === $fieldName || FALSE === isset($row[$fieldName]) || FALSE === isset($record[$fieldName]['data']) || FALSE === is_array($record[$fieldName]['data']);
         if (TRUE === $dontProcess) {
             return;
         }
         $data = $record[$fieldName]['data'];
         foreach ($data as $sheetName => $sheetFields) {
             foreach ($sheetFields['lDEF'] as $sheetFieldName => $fieldDefinition) {
                 if ('_clear' === substr($sheetFieldName, -6)) {
                     array_push($removals, $sheetFieldName);
                 } else {
                     $clearFieldName = $sheetFieldName . '_clear';
                     $clearFieldValue = (bool) (TRUE === isset($data[$sheetName]['lDEF'][$clearFieldName]['vDEF']) ? $data[$sheetName]['lDEF'][$clearFieldName]['vDEF'] : 0);
                     $shouldClearField = 0 < $data[$sheetName]['lDEF'][$clearFieldName]['vDEF'];
                     if (TRUE === $shouldClearField || TRUE === $clearFieldValue) {
                         array_push($removals, $sheetFieldName);
                     }
                 }
             }
         }
         $stored[$fieldName] = MiscellaneousUtility::cleanFlexFormXml($row[$fieldName], $removals);
         $row[$fieldName] = $stored[$fieldName];
         $reference->datamap[$this->tableName][$id][$fieldName] = $row[$fieldName];
         $this->recordService->update($this->tableName, $stored);
     }
 }