TYPO3 CMS  TYPO3_7-6
InlineOverrideChildTca.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 
19 
24 {
31  public function addData(array $result)
32  {
33  // Replace types definition of inline child if foreign_types is defined in inlineParentConfig
34  if (isset($result['inlineParentConfig']['foreign_types'])) {
35  foreach ($result['inlineParentConfig']['foreign_types'] as $type => $config) {
36  $result['processedTca']['types'][$type] = $config;
37  }
38  }
39 
40  // Override config section of foreign_selector field pointer if given
41  if (isset($result['inlineParentConfig']['foreign_selector'])
42  && is_string($result['inlineParentConfig']['foreign_selector'])
43  && isset($result['inlineParentConfig']['foreign_selector_fieldTcaOverride'])
44  && is_array($result['inlineParentConfig']['foreign_selector_fieldTcaOverride'])
45  && isset($result['processedTca']['columns'][$result['inlineParentConfig']['foreign_selector']])
46  && is_array($result['processedTca']['columns'][$result['inlineParentConfig']['foreign_selector']])
47  ) {
49  $result['processedTca']['columns'][$result['inlineParentConfig']['foreign_selector']],
50  $result['inlineParentConfig']['foreign_selector_fieldTcaOverride']
51  );
52  }
53 
54  // Set default values for (new) child if foreign_record_defaults is defined in inlineParentConfig
55  if (isset($result['inlineParentConfig']['foreign_record_defaults']) && is_array($result['inlineParentConfig']['foreign_record_defaults'])) {
56  $foreignTableConfig = $GLOBALS['TCA'][$result['inlineParentConfig']['foreign_table']];
57  // The following system relevant fields can't be set by foreign_record_defaults
58  $notSetableFields = [
59  'uid',
60  'pid',
61  't3ver_oid',
62  't3ver_id',
63  't3ver_label',
64  't3ver_wsid',
65  't3ver_state',
66  't3ver_stage',
67  't3ver_count',
68  't3ver_tstamp',
69  't3ver_move_id',
70  ];
71  // Optional configuration fields used in child table. If set, they must not be overridden, either
72  $configurationKeysForNotSettableFields = [
73  'crdate',
74  'cruser_id',
75  'delete',
76  'origUid',
77  'transOrigDiffSourceField',
78  'transOrigPointerField',
79  'tstamp',
80  ];
81  foreach ($configurationKeysForNotSettableFields as $configurationKey) {
82  if (isset($foreignTableConfig['ctrl'][$configurationKey])) {
83  $notSetableFields[] = $foreignTableConfig['ctrl'][$configurationKey];
84  }
85  }
86  foreach ($result['inlineParentConfig']['foreign_record_defaults'] as $fieldName => $defaultValue) {
87  if (isset($foreignTableConfig['columns'][$fieldName]) && !in_array($fieldName, $notSetableFields, true)) {
88  $result['processedTca']['columns'][$fieldName]['config']['default'] = $defaultValue;
89  }
90  }
91  }
92  return $result;
93  }
94 }
static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=true, $includeEmptyValues=true, $enableUnsetFeature=true)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']