/
DataStructureV11Controller.php
202 lines (184 loc) · 7.6 KB
/
DataStructureV11Controller.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<?php
namespace Tvp\TemplaVoilaPlus\Controller\Backend\ControlCenter\Update;
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
use Tvp\TemplaVoilaPlus\Utility\TemplaVoilaUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\StringUtility;
/**
* Controller to migrate/update the DataStructure for TYPO3 v11 LTS
*
* @author Alexander Opitz <opitz@extrameile-gehen.de>
*/
class DataStructureV11Controller extends AbstractUpdateController
{
protected $errors = [];
protected function stepStartAction()
{
}
protected function stepFinalAction()
{
/** @var DataStructureUpdateHandler */
$handler = GeneralUtility::makeInstance(DataStructureUpdateHandler::class);
$count = $handler->updateAllDs(
[],
[
[$this, 'migrateColumnsConfig'],
[$this, 'migrateLocalizeChildrenAtParentLocalization'],
[$this, 'removeEnableMultiSelectFilterTextfieldConfiguration'],
[$this, 'migrateSpecialLanguagesToTcaTypeLanguage'],
[$this, 'removeShowRemovedLocalizationRecords'],
[$this, 'migrateFileFolderConfiguration'],
[$this, 'migrateLevelLinksPosition'],
[$this, 'migrateRootUidToStartingPoints'],
]
);
$this->view->assignMultiple([
'countStatic' => $countStatic,
'count' => $count,
'errors' => $this->errors,
]);
}
/**
* Find columns fields that don't have a 'config' section at all, add
* ['config']['type'] = 'none'; for those to enforce config
*/
public function migrateColumnsConfig(array &$element): bool
{
$changed = false;
if ((!isset($element['TCEforms']['config']) || !is_array($element['TCEforms']['config'])) && !isset($element['TCEforms']['type'])) {
$element['TCEforms']['config'] = [
'type' => 'none',
];
$changed = true;
}
return $changed;
}
/**
* Option $TCA[$table]['columns'][$columnName]['config']['behaviour']['localizeChildrenAtParentLocalization']
* is always on, so this option can be removed.
*/
public function migrateLocalizeChildrenAtParentLocalization(array &$element): bool
{
$changed = false;
if (isset($element['TCEforms']['config']['behaviour']['localizeChildrenAtParentLocalization'])) {
unset($element['TCEforms']['config']['behaviour']['localizeChildrenAtParentLocalization']);
$changed = true;
}
return $changed;
}
/**
* Removes configuration removeEnableMultiSelectFilterTextfield
*/
public function removeEnableMultiSelectFilterTextfieldConfiguration(array &$element): bool
{
$changed = false;
if (isset($element['TCEforms']['config']['enableMultiSelectFilterTextfield'])) {
unset($element['TCEforms']['config']['enableMultiSelectFilterTextfield']);
$changed = true;
}
return $changed;
}
/**
* Replaces $TCA[$mytable][columns][field][config][special] = 'languages' with
* $TCA[$mytable][columns][field][config][type] = 'language'
*/
public function migrateSpecialLanguagesToTcaTypeLanguage(array &$element): bool
{
$changed = false;
if ((string)($element['TCEforms']['config']['type']) === 'select'
&& (string)($element['TCEforms']['config']['special']) === 'languages'
) {
$element['TCEforms']['config'] = [
'type' => 'language',
];
$changed = true;
}
return $changed;
}
public function removeShowRemovedLocalizationRecords(array &$element): bool
{
$changed = false;
if ((string)($element['TCEforms']['config']['type']) === 'inline'
&& isset($element['TCEforms']['config']['appearance']['showRemovedLocalizationRecords'])
) {
unset($element['TCEforms']['config']['appearance']['showRemovedLocalizationRecords']);
$changed = true;
}
return $changed;
}
/**
* Moves the "fileFolder" configuration of TCA columns type=select
* into sub array "fileFolderConfig", while renaming those options.
*/
public function migrateFileFolderConfiguration(array &$element): bool
{
$changed = false;
if ((string)($element['TCEforms']['config']['type']) === 'select'
&& isset($element['TCEforms']['config']['fileFolder'])
) {
$element['TCEforms']['config']['fileFolderConfig'] = [
'folder' => $element['TCEforms']['config']['fileFolder'],
];
unset($element['TCEforms']['config']['fileFolder']);
if (isset($element['TCEforms']['config']['fileFolder_extList'])) {
$element['TCEforms']['config']['fileFolderConfig']['allowedExtensions'] = $element['TCEforms']['config']['fileFolder_extList'];
unset($element['TCEforms']['config']['fileFolder_extList']);
}
if (isset($element['TCEforms']['config']['fileFolder_recursions'])) {
$element['TCEforms']['config']['fileFolderConfig']['depth'] = $element['TCEforms']['config']['fileFolder_recursions'];
unset($element['TCEforms']['config']['fileFolder_recursions']);
}
$changed = true;
}
return $changed;
}
/**
* The [appearance][levelLinksPosition] option can be used
* to select the position of the level links. This option
* was previously misused to disable all those links by
* setting it to "none". Since all of those links can be
* disabled by a dedicated option, e.g. showNewRecordLink,
* this wizard sets those options to false and unsets the
* invalid levelLinksPosition value.
*/
public function migrateLevelLinksPosition(array &$element): bool
{
$changed = false;
if ((string)($element['TCEforms']['config']['type']) === 'inline'
&& (string)($element['TCEforms']['config']['appearance']['levelLinksPosition']) === 'none'
) {
unset($element['TCEforms']['config']['appearance']['levelLinksPosition']);
$element['TCEforms']['config']['appearance']['showAllLocalizationLink'] = false;
$element['TCEforms']['config']['appearance']['showSynchronizationLink'] = false;
$element['TCEforms']['config']['appearance']['showNewRecordLink'] = false;
$changed = true;
}
return $changed;
}
/**
* If a column has [treeConfig][rootUid] defined, migrate to [treeConfig][startingPoints] on the same level.
*/
public function migrateRootUidToStartingPoints(array &$element): bool
{
$changed = false;
if ((int)($element['TCEforms']['config']['treeConfig']['rootUid'] ?? 0) !== 0
&& in_array((string)($element['TCEforms']['config']['type']), ['select', 'category'], true)
) {
$element['TCEforms']['config']['treeConfig']['startingPoints'] = (string)(int)($element['TCEforms']['config']['treeConfig']['rootUid']);
unset($element['TCEforms']['config']['treeConfig']['rootUid']);
$changed = true;
}
return $changed;
}
}