‪TYPO3CMS  11.5
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  ];
44 
53  'crdate',
54  'cruser_id',
55  'delete',
56  'origUid',
57  'transOrigDiffSourceField',
58  'transOrigPointerField',
59  'tstamp',
60  ];
61 
68  public function ‪addData(array $result): array
69  {
70  $result = $this->‪overrideTypes($result);
71  return $this->‪overrideColumns($result);
72  }
73 
80  protected function ‪overrideTypes(array $result): array
81  {
82  if (!isset($result['inlineParentConfig']['overrideChildTca']['types'])) {
83  return $result;
84  }
85  $result['processedTca']['types'] = array_replace_recursive(
86  $result['processedTca']['types'],
87  $result['inlineParentConfig']['overrideChildTca']['types']
88  );
89  return $result;
90  }
91 
100  protected function ‪overrideColumns(array $result): array
101  {
102  if (!isset($result['inlineParentConfig']['overrideChildTca']['columns'])) {
103  return $result;
104  }
105  $fieldBlackList = $this->‪generateFieldBlackList($result);
106  foreach ($fieldBlackList as $notChangeableFieldName) {
107  if (isset($result['inlineParentConfig']['overrideChildTca']['columns'][$notChangeableFieldName])) {
108  throw new \RuntimeException(
109  'System field \'' . $notChangeableFieldName . '\' can not be overridden in inline config'
110  . ' \'overrideChildTca\' from parent TCA',
111  1490371322
112  );
113  }
114  }
115  $result['processedTca']['columns'] = array_replace_recursive(
116  $result['processedTca']['columns'],
117  $result['inlineParentConfig']['overrideChildTca']['columns']
118  );
119  return $result;
120  }
121 
128  protected function ‪generateFieldBlackList(array $result): array
129  {
131  foreach ($this->configurationKeysForNotSettableFields as $configurationKey) {
132  if (isset($result['processedTca']['ctrl'][$configurationKey])) {
133  ‪$notSettableFields[] = $result['processedTca']['ctrl'][$configurationKey];
134  }
135  }
136  return ‪$notSettableFields;
137  }
138 }
‪TYPO3\CMS\Backend\Form\FormDataProvider\InlineOverrideChildTca\overrideTypes
‪array overrideTypes(array $result)
Definition: InlineOverrideChildTca.php:78
‪TYPO3\CMS\Backend\Form\FormDataProvider\InlineOverrideChildTca\generateFieldBlackList
‪array generateFieldBlackList(array $result)
Definition: InlineOverrideChildTca.php:126
‪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:66
‪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:98
‪TYPO3\CMS\Backend\Form\FormDataProvider\InlineOverrideChildTca
Definition: InlineOverrideChildTca.php:29
‪TYPO3\CMS\Backend\Form\FormDataProvider\InlineOverrideChildTca\$configurationKeysForNotSettableFields
‪array $configurationKeysForNotSettableFields
Definition: InlineOverrideChildTca.php:50