diff --git a/Classes/DataProcessing/ExplodeProcessor.php b/Classes/DataProcessing/ExplodeProcessor.php index 6e00569..0349f8f 100644 --- a/Classes/DataProcessing/ExplodeProcessor.php +++ b/Classes/DataProcessing/ExplodeProcessor.php @@ -33,13 +33,6 @@ class ExplodeProcessor implements ProcessorInterface $configuration['delimiter'] = ' '; } - if (is_array($record[$configuration['field']])) { - $record[$configuration['field']] = implode( - $configuration['delimiter'], - $record[$configuration['field']] - ); - } - $record[$configuration['field']] = GeneralUtility::trimExplode( $configuration['delimiter'], $record[$configuration['field']], diff --git a/Classes/DataProcessing/ReplaceProcessor.php b/Classes/DataProcessing/ReplaceProcessor.php new file mode 100644 index 0000000..08beee9 --- /dev/null +++ b/Classes/DataProcessing/ReplaceProcessor.php @@ -0,0 +1,42 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +/** + * Execute a regular expression replacement. + */ +class ReplaceProcessor implements ProcessorInterface +{ + public function processRecord(array $record, array $configuration) + { + if (!isset($configuration['replacement'])) { + $configuration['replacement'] = ' '; + } + + $record[$configuration['field']] = preg_replace( + $configuration['regularExpression'], + $configuration['replacement'], + $record[$configuration['field']] + ); + + return $record; + } +} diff --git a/Classes/DataProcessing/UniqueProcessor.php b/Classes/DataProcessing/UniqueProcessor.php new file mode 100644 index 0000000..643f78d --- /dev/null +++ b/Classes/DataProcessing/UniqueProcessor.php @@ -0,0 +1,34 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +/** + * Execute on a single field to make entries unique. + */ +class UniqueProcessor implements ProcessorInterface +{ + public function processRecord(array $record, array $configuration) + { + $record[$configuration['field']] = array_values(array_unique($record[$configuration['field']])); + + return $record; + } +}