mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-23 22:36:11 +01:00
TASK: Add another two processors
This commit is contained in:
parent
a16bc2a60b
commit
0307471cf6
3 changed files with 76 additions and 7 deletions
|
@ -33,13 +33,6 @@ class ExplodeProcessor implements ProcessorInterface
|
||||||
$configuration['delimiter'] = ' ';
|
$configuration['delimiter'] = ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($record[$configuration['field']])) {
|
|
||||||
$record[$configuration['field']] = implode(
|
|
||||||
$configuration['delimiter'],
|
|
||||||
$record[$configuration['field']]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$record[$configuration['field']] = GeneralUtility::trimExplode(
|
$record[$configuration['field']] = GeneralUtility::trimExplode(
|
||||||
$configuration['delimiter'],
|
$configuration['delimiter'],
|
||||||
$record[$configuration['field']],
|
$record[$configuration['field']],
|
||||||
|
|
42
Classes/DataProcessing/ReplaceProcessor.php
Normal file
42
Classes/DataProcessing/ReplaceProcessor.php
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
namespace Codappix\SearchCore\DataProcessing;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||||
|
*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
34
Classes/DataProcessing/UniqueProcessor.php
Normal file
34
Classes/DataProcessing/UniqueProcessor.php
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
<?php
|
||||||
|
namespace Codappix\SearchCore\DataProcessing;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2017 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||||
|
*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue