‪TYPO3CMS  9.5
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 }
‪TYPO3\CMS\Frontend\DataProcessing\SplitProcessor\process
‪array process(ContentObjectRenderer $cObj, array $contentObjectConfiguration, array $processorConfiguration, array $processedData)
Definition: SplitProcessor.php:55
‪TYPO3\CMS\Frontend\DataProcessing
Definition: CommaSeparatedValueProcessor.php:2
‪TYPO3\CMS\Frontend\DataProcessing\SplitProcessor
Definition: SplitProcessor.php:45
‪TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface
Definition: DataProcessorInterface.php:22
‪TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\stdWrapValue
‪string stdWrapValue($key, array $config, $defaultValue='')
Definition: ContentObjectRenderer.php:1637
‪TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
Definition: ContentObjectRenderer.php:91
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\checkIf
‪bool checkIf($conf)
Definition: ContentObjectRenderer.php:3059