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