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