TYPO3 CMS  TYPO3_7-6
SplitProcessor.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 
45 {
55  public function process(ContentObjectRenderer $cObj, array $contentObjectConfiguration, array $processorConfiguration, array $processedData)
56  {
57  if (isset($processorConfiguration['if.']) && !$cObj->checkIf($processorConfiguration['if.'])) {
58  return $processedData;
59  }
60 
61  // The field name to process
62  $fieldName = $cObj->stdWrapValue('fieldName', $processorConfiguration);
63  if (empty($fieldName)) {
64  return $processedData;
65  }
66 
67  $originalValue = $cObj->data[$fieldName];
68 
69  // Set the target variable
70  $targetVariableName = $cObj->stdWrapValue('as', $processorConfiguration, $fieldName);
71 
72  // Set the delimiter which is "LF" by default
73  $delimiter = $cObj->stdWrapValue('delimiter', $processorConfiguration, LF);
74 
75  // Filter integers
76  $filterIntegers = (bool)$cObj->stdWrapValue('filterIntegers', $processorConfiguration, false);
77 
78  // Filter unique
79  $filterUnique = (bool)$cObj->stdWrapValue('filterUnique', $processorConfiguration, false);
80 
81  // Remove empty entries
82  $removeEmptyEntries = (bool)$cObj->stdWrapValue('removeEmptyEntries', $processorConfiguration, false);
83 
84  if ($filterIntegers === true) {
85  $processedData[$targetVariableName] = GeneralUtility::intExplode($delimiter, $originalValue, $removeEmptyEntries);
86  } else {
87  $processedData[$targetVariableName] = GeneralUtility::trimExplode($delimiter, $originalValue, $removeEmptyEntries);
88  }
89 
90  if ($filterUnique === true) {
91  $processedData[$targetVariableName] = array_unique($processedData[$targetVariableName]);
92  }
93 
94  return $processedData;
95  }
96 }
process(ContentObjectRenderer $cObj, array $contentObjectConfiguration, array $processorConfiguration, array $processedData)
static intExplode($delimiter, $string, $removeEmptyValues=false, $limit=0)
static trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)