TYPO3  7.6
PageTsConfigMerged.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Backend\Form\FormDataProvider;
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  $mergedTsConfig = $result['pageTsConfig'];
34 
35  if (empty($result['pageTsConfig']['TCEFORM.']) || !is_array($result['pageTsConfig']['TCEFORM.'])) {
36  $result['pageTsConfig'] = $mergedTsConfig;
37  return $result;
38  }
39 
40  $mergedTsConfig = $result['pageTsConfig'];
41  $type = $result['recordTypeValue'];
42  $table = $result['tableName'];
43 
44  // Merge TCEFORM.[table name].[field].types.[type] over TCEFORM.[table name].[field]
45  if (!empty($result['pageTsConfig']['TCEFORM.'][$table . '.'])
46  && is_array($result['pageTsConfig']['TCEFORM.'][$table . '.'])
47  ) {
48  foreach ($result['pageTsConfig']['TCEFORM.'][$table . '.'] as $fieldNameWithDot => $fullFieldConfiguration) {
49  $newFieldConfiguration = $fullFieldConfiguration;
50  if (!empty($fullFieldConfiguration['types.']) && is_array($fullFieldConfiguration['types.'])) {
51  $typeSpecificConfiguration = $newFieldConfiguration['types.'];
52  unset($newFieldConfiguration['types.']);
53  if (!empty($typeSpecificConfiguration[$type . '.']) && is_array($typeSpecificConfiguration[$type . '.'])) {
54  ArrayUtility::mergeRecursiveWithOverrule($newFieldConfiguration, $typeSpecificConfiguration[$type . '.']);
55  }
56  }
57  $mergedTsConfig['TCEFORM.'][$table . '.'][$fieldNameWithDot] = $newFieldConfiguration;
58  }
59  }
60 
61  $result['pageTsConfig'] = $mergedTsConfig;
62 
63  return $result;
64  }
65 }