‪TYPO3CMS  10.4
CommaSeparatedValueProcessor.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 
58 {
68  public function ‪process(‪ContentObjectRenderer $cObj, array $contentObjectConfiguration, array $processorConfiguration, array $processedData)
69  {
70  if (isset($processorConfiguration['if.']) && !$cObj->‪checkIf($processorConfiguration['if.'])) {
71  return $processedData;
72  }
73 
74  // The field name to process
75  $fieldName = $cObj->‪stdWrapValue('fieldName', $processorConfiguration);
76  if (empty($fieldName)) {
77  return $processedData;
78  }
79 
80  $originalValue = $cObj->data[$fieldName];
81 
82  // Set the target variable
83  $targetVariableName = $cObj->‪stdWrapValue('as', $processorConfiguration, $fieldName);
84 
85  // Set the maximum amount of columns
86  $maximumColumns = $cObj->‪stdWrapValue('maximumColumns', $processorConfiguration, 0);
87 
88  // Set the field delimiter which is "," by default
89  $fieldDelimiter = (string)$cObj->‪stdWrapValue('fieldDelimiter', $processorConfiguration, ',');
90 
91  // Set the field enclosure which is " by default
92  $fieldEnclosure = (string)$cObj->‪stdWrapValue('fieldEnclosure', $processorConfiguration, '"');
93 
94  $processedData[$targetVariableName] = ‪CsvUtility::csvToArray(
95  $originalValue,
96  $fieldDelimiter,
97  $fieldEnclosure,
98  (int)$maximumColumns
99  );
100 
101  return $processedData;
102  }
103 }
‪TYPO3\CMS\Core\Utility\CsvUtility\csvToArray
‪static array csvToArray($input, $fieldDelimiter=',', $fieldEnclosure='"', $maximumColumns = 0)
Definition: CsvUtility.php:52
‪TYPO3\CMS\Frontend\DataProcessing\CommaSeparatedValueProcessor
Definition: CommaSeparatedValueProcessor.php:58
‪TYPO3\CMS\Frontend\DataProcessing
Definition: CommaSeparatedValueProcessor.php:16
‪TYPO3\CMS\Frontend\DataProcessing\CommaSeparatedValueProcessor\process
‪array process(ContentObjectRenderer $cObj, array $contentObjectConfiguration, array $processorConfiguration, array $processedData)
Definition: CommaSeparatedValueProcessor.php:68
‪TYPO3\CMS\Core\Utility\CsvUtility
Definition: CsvUtility.php:24
‪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\Frontend\ContentObject\ContentObjectRenderer
Definition: ContentObjectRenderer.php:97
‪TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\checkIf
‪bool checkIf($conf)
Definition: ContentObjectRenderer.php:3074