‪TYPO3CMS  10.4
InlineOverrideChildTca.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 
29 {
36  protected ‪$notSettableFields = [
37  'uid',
38  'pid',
39  't3ver_oid',
40  't3ver_wsid',
41  't3ver_state',
42  't3ver_stage',
43  't3ver_count',
44  't3ver_tstamp',
45  't3ver_move_id',
46  ];
47 
56  'crdate',
57  'cruser_id',
58  'delete',
59  'origUid',
60  'transOrigDiffSourceField',
61  'transOrigPointerField',
62  'tstamp',
63  ];
64 
71  public function ‪addData(array $result): array
72  {
73  $result = $this->‪overrideTypes($result);
74  return $this->‪overrideColumns($result);
75  }
76 
83  protected function ‪overrideTypes(array $result): array
84  {
85  if (!isset($result['inlineParentConfig']['overrideChildTca']['types'])) {
86  return $result;
87  }
88  $result['processedTca']['types'] = array_replace_recursive(
89  $result['processedTca']['types'],
90  $result['inlineParentConfig']['overrideChildTca']['types']
91  );
92  return $result;
93  }
94 
103  protected function ‪overrideColumns(array $result): array
104  {
105  if (!isset($result['inlineParentConfig']['overrideChildTca']['columns'])) {
106  return $result;
107  }
108  $fieldBlackList = $this->‪generateFieldBlackList($result);
109  foreach ($fieldBlackList as $notChangeableFieldName) {
110  if (isset($result['inlineParentConfig']['overrideChildTca']['columns'][$notChangeableFieldName])) {
111  throw new \RuntimeException(
112  'System field \'' . $notChangeableFieldName . '\' can not be overridden in inline config'
113  . ' \'overrideChildTca\' from parent TCA',
114  1490371322
115  );
116  }
117  }
118  $result['processedTca']['columns'] = array_replace_recursive(
119  $result['processedTca']['columns'],
120  $result['inlineParentConfig']['overrideChildTca']['columns']
121  );
122  return $result;
123  }
124 
131  protected function ‪generateFieldBlackList(array $result): array
132  {
134  foreach ($this->configurationKeysForNotSettableFields as $configurationKey) {
135  if (isset($result['processedTca']['ctrl'][$configurationKey])) {
136  ‪$notSettableFields[] = $result['processedTca']['ctrl'][$configurationKey];
137  }
138  }
139  return ‪$notSettableFields;
140  }
141 }
‪TYPO3\CMS\Backend\Form\FormDataProvider\InlineOverrideChildTca\overrideTypes
‪array overrideTypes(array $result)
Definition: InlineOverrideChildTca.php:81
‪TYPO3\CMS\Backend\Form\FormDataProvider\InlineOverrideChildTca\generateFieldBlackList
‪array generateFieldBlackList(array $result)
Definition: InlineOverrideChildTca.php:129
‪TYPO3\CMS\Backend\Form\FormDataProvider\InlineOverrideChildTca\$notSettableFields
‪array $notSettableFields
Definition: InlineOverrideChildTca.php:35
‪TYPO3\CMS\Backend\Form\FormDataProvider\InlineOverrideChildTca\addData
‪array addData(array $result)
Definition: InlineOverrideChildTca.php:69
‪TYPO3\CMS\Backend\Form\FormDataProvider
Definition: AbstractDatabaseRecordProvider.php:16
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:23
‪TYPO3\CMS\Backend\Form\FormDataProvider\InlineOverrideChildTca\overrideColumns
‪array overrideColumns(array $result)
Definition: InlineOverrideChildTca.php:101
‪TYPO3\CMS\Backend\Form\FormDataProvider\InlineOverrideChildTca
Definition: InlineOverrideChildTca.php:29
‪TYPO3\CMS\Backend\Form\FormDataProvider\InlineOverrideChildTca\$configurationKeysForNotSettableFields
‪array $configurationKeysForNotSettableFields
Definition: InlineOverrideChildTca.php:53