/** * 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); } }
/** * @param string $xml * @param array $removals * @param string $expected * @dataProvider getCleanFlexFormXmlTestValues * @test */ public function testCleanFlexFormXml($xml, array $removals, $expected) { $result = MiscellaneousUtility::cleanFlexFormXml($xml, $removals); $this->assertEquals($expected, $result); }