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