‪TYPO3CMS  10.4
TcaColumnsProcessShowitem.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 
20 
25 {
33  public function ‪addData(array $result)
34  {
35  $recordTypeValue = $result['recordTypeValue'];
36 
37  if (!isset($result['processedTca']['types'][$recordTypeValue]['showitem'])
38  || !is_string($result['processedTca']['types'][$recordTypeValue]['showitem'])
39  ) {
40  throw new \UnexpectedValueException(
41  'No or invalid showitem definition in TCA table ' . $result['tableName'] . ' for type ' . $recordTypeValue,
42  1438614542
43  );
44  }
45 
46  if (empty($result['processedTca']['columns'])) {
47  // We are sure this is an array by InitializeProcessedTca data provider
48  return $result;
49  }
50 
51  if ($result['isInlineChild'] && !$result['isInlineChildExpanded']) {
52  // If the record is an inline child that is not expanded, it is not necessary to calculate all fields
53  return $result;
54  }
55 
56  $showItemFieldString = $result['processedTca']['types'][$recordTypeValue]['showitem'];
57  $showItemFieldArray = ‪GeneralUtility::trimExplode(',', $showItemFieldString, true);
58 
59  foreach ($showItemFieldArray as $fieldConfigurationString) {
60  $fieldConfigurationArray = ‪GeneralUtility::trimExplode(';', $fieldConfigurationString);
61  $fieldName = $fieldConfigurationArray[0];
62  if ($fieldName === '--div--') {
63  continue;
64  }
65  if ($fieldName === '--palette--') {
66  if (isset($fieldConfigurationArray[2])) {
67  $paletteName = $fieldConfigurationArray[2];
68  if (!empty($result['processedTca']['palettes'][$paletteName]['showitem'])) {
69  $paletteFields = ‪GeneralUtility::trimExplode(',', $result['processedTca']['palettes'][$paletteName]['showitem'], true);
70  foreach ($paletteFields as $paletteFieldConfiguration) {
71  $paletteFieldConfigurationArray = ‪GeneralUtility::trimExplode(';', $paletteFieldConfiguration);
72  $result['columnsToProcess'][] = $paletteFieldConfigurationArray[0];
73  }
74  }
75  }
76  } else {
77  $result['columnsToProcess'][] = $fieldName;
78  }
79  }
80 
81  return $result;
82  }
83 }
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsProcessShowitem\addData
‪array addData(array $result)
Definition: TcaColumnsProcessShowitem.php:33
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaColumnsProcessShowitem
Definition: TcaColumnsProcessShowitem.php:25
‪TYPO3\CMS\Backend\Form\FormDataProvider
Definition: AbstractDatabaseRecordProvider.php:16
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:23
‪TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode
‪static string[] trimExplode($delim, $string, $removeEmptyValues=false, $limit=0)
Definition: GeneralUtility.php:1059
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46