[TASK] Cleanup TCA select field configuration
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Migrations / TcaMigration.php
1 <?php
2 namespace TYPO3\CMS\Core\Migrations;
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
17 use TYPO3\CMS\Core\Utility\GeneralUtility;
18 use TYPO3\CMS\Core\Utility\StringUtility;
19
20 /**
21 * Migrate TCA from old to new syntax. Used in bootstrap and Flex Form Data Structures.
22 *
23 * @internal Class and API may change any time.
24 */
25 class TcaMigration {
26
27 /**
28 * Accumulate migration messages
29 *
30 * @var array
31 */
32 protected $messages = array();
33
34 /**
35 * Migrate old TCA to new TCA.
36 *
37 * See unit tests for details.
38 *
39 * @param array $tca
40 * @return array
41 */
42 public function migrate(array $tca) {
43 $tca = $this->migrateT3editorWizardToRenderTypeT3editorIfNotEnabledByTypeConfig($tca);
44 $tca = $this->migrateSpecialConfigurationAndRemoveShowItemStylePointerConfig($tca);
45 $tca = $this->migrateT3editorWizardWithEnabledByTypeConfigToColumnsOverrides($tca);
46 $tca = $this->migrateShowItemAdditionalPaletteToOwnPalette($tca);
47 $tca = $this->migrateIconsForFormFieldWizardsToNewLocation($tca);
48 $tca = $this->migrateExtAndSysextPathToEXTPath($tca);
49 $tca = $this->migrateIconsInOptionTags($tca);
50 $tca = $this->migrateIconfileRelativePathOrFilenameOnlyToExtReference($tca);
51 $tca = $this->migrateSelectFieldRenderType($tca);
52 // @todo: if showitem/defaultExtras wizards[xy] is migrated to columnsOverrides here, enableByTypeConfig could be dropped
53 return $tca;
54 }
55
56 /**
57 * Get messages of migrated fields. Can be used for deprecation messages after migrate() was called.
58 *
59 * @return array Migration messages
60 */
61 public function getMessages() {
62 return $this->messages;
63 }
64
65 /**
66 * Migrate type=text field with t3editor wizard to renderType=t3editor without this wizard
67 *
68 * @param array $tca Incoming TCA
69 * @return array Migrated TCA
70 */
71 protected function migrateT3editorWizardToRenderTypeT3editorIfNotEnabledByTypeConfig(array $tca) {
72 $newTca = $tca;
73 foreach ($tca as $table => $tableDefinition) {
74 if (!isset($tableDefinition['columns']) || !is_array($tableDefinition['columns'])) {
75 continue;
76 }
77 foreach ($tableDefinition['columns'] as $fieldName => $fieldConfig) {
78 if (
79 !empty($fieldConfig['config']['type']) // type is set
80 && trim($fieldConfig['config']['type']) === 'text' // to "text"
81 && isset($fieldConfig['config']['wizards'])
82 && is_array($fieldConfig['config']['wizards']) // and there are wizards
83 ) {
84 foreach ($fieldConfig['config']['wizards'] as $wizardName => $wizardConfig) {
85 if (
86 !empty($wizardConfig['userFunc']) // a userFunc is defined
87 && trim($wizardConfig['userFunc']) === 'TYPO3\\CMS\\T3editor\\FormWizard->main' // and set to FormWizard
88 && (
89 !isset($wizardConfig['enableByTypeConfig']) // and enableByTypeConfig is not set
90 || (isset($wizardConfig['enableByTypeConfig']) && !$wizardConfig['enableByTypeConfig']) // or set, but not enabled
91 )
92 ) {
93 // Set renderType from text to t3editor
94 $newTca[$table]['columns'][$fieldName]['config']['renderType'] = 't3editor';
95 // Unset this wizard definition
96 unset($newTca[$table]['columns'][$fieldName]['config']['wizards'][$wizardName]);
97 // Move format parameter
98 if (!empty($wizardConfig['params']['format'])) {
99 $newTca[$table]['columns'][$fieldName]['config']['format'] = $wizardConfig['params']['format'];
100 }
101 $this->messages[] = 'Migrated t3editor wizard in TCA of table "' . $table . '" field "' . $fieldName . '" to a renderType definition.';
102 }
103 }
104 // If no wizard is left after migration, unset the whole sub array
105 if (empty($newTca[$table]['columns'][$fieldName]['config']['wizards'])) {
106 unset($newTca[$table]['columns'][$fieldName]['config']['wizards']);
107 }
108 }
109 }
110 }
111 return $newTca;
112 }
113
114 /**
115 * Remove "style pointer", the 5th parameter from "types" "showitem" configuration.
116 * Move "specConf", 4th parameter from "tyes" "showitem" to "types" "columnsOverrides.
117 *
118 * @param array $tca Incoming TCA
119 * @return array Modified TCA
120 */
121 protected function migrateSpecialConfigurationAndRemoveShowItemStylePointerConfig(array $tca) {
122 $newTca = $tca;
123 foreach ($tca as $table => $tableDefinition) {
124 if (!isset($tableDefinition['types']) || !is_array($tableDefinition['types'])) {
125 continue;
126 }
127 foreach ($tableDefinition['types'] as $typeName => $typeArray) {
128 if (!is_string($typeArray['showitem']) || strpos($typeArray['showitem'], ';') === FALSE) {
129 // Continue directly if no semicolon is found
130 continue;
131 }
132 $itemList = GeneralUtility::trimExplode(',', $typeArray['showitem'], TRUE);
133 $newFieldStrings = array();
134 foreach ($itemList as $fieldString) {
135 $fieldString = rtrim($fieldString, ';');
136 // Unpack the field definition, migrate and remove as much as possible
137 // Keep empty parameters in trimExplode here (third parameter FALSE), so position is not changed
138 $fieldArray = GeneralUtility::trimExplode(';', $fieldString);
139 $fieldArray = array(
140 'fieldName' => isset($fieldArray[0]) ? $fieldArray[0] : '',
141 'fieldLabel' => isset($fieldArray[1]) ? $fieldArray[1] : NULL,
142 'paletteName' => isset($fieldArray[2]) ? $fieldArray[2] : NULL,
143 'fieldExtra' => isset($fieldArray[3]) ? $fieldArray[3] : NULL,
144 );
145 $fieldName = $fieldArray['fieldName'];
146 if (!empty($fieldArray['fieldExtra'])) {
147 // Move fieldExtra "specConf" to columnsOverrides "defaultExtras"
148 if (!isset($newTca[$table]['types'][$typeName]['columnsOverrides'])) {
149 $newTca[$table]['types'][$typeName]['columnsOverrides'] = array();
150 }
151 if (!isset($newTca[$table]['types'][$typeName]['columnsOverrides'][$fieldArray['fieldName']])) {
152 $newTca[$table]['types'][$typeName]['columnsOverrides'][$fieldArray['fieldName']] = array();
153 }
154 // Merge with given defaultExtras from columns.
155 // They will be the first part of the string, so if "specConf" from types changes the same settings,
156 // those will override settings from defaultExtras of columns
157 $newDefaultExtras = array();
158 if (!empty($tca[$table]['columns'][$fieldArray['fieldName']]['defaultExtras'])) {
159 $newDefaultExtras[] = $tca[$table]['columns'][$fieldArray['fieldName']]['defaultExtras'];
160 }
161 $newDefaultExtras[] = $fieldArray['fieldExtra'];
162 $newTca[$table]['types'][$typeName]['columnsOverrides'][$fieldArray['fieldName']]['defaultExtras'] = implode(':', $newDefaultExtras);
163 }
164 unset($fieldArray['fieldExtra']);
165 if (count($fieldArray) === 3 && empty($fieldArray['paletteName'])) {
166 unset($fieldArray['paletteName']);
167 }
168 if (count($fieldArray) === 2 && empty($fieldArray['fieldLabel'])) {
169 unset($fieldArray['fieldLabel']);
170 }
171 if (count($fieldArray) === 1 && empty($fieldArray['fieldName'])) {
172 // The field may vanish if nothing is left
173 unset($fieldArray['fieldName']);
174 }
175 $newFieldString = implode(';', $fieldArray);
176 if ($newFieldString !== $fieldString) {
177 $this->messages[] = 'Changed showitem string of TCA table "' . $table . '" type "' . $typeName . '" due to changed field "' . $fieldName . '".';
178 }
179 if (!empty($newFieldString)) {
180 $newFieldStrings[] = $newFieldString;
181 }
182 }
183 $newTca[$table]['types'][$typeName]['showitem'] = implode(',', $newFieldStrings);
184 }
185 }
186 return $newTca;
187 }
188
189 /**
190 * Migrate type=text field with t3editor wizard that is "enableByTypeConfig" to columnsOverrides
191 * with renderType=t3editor
192 *
193 * @param array $tca Incoming TCA
194 * @return array Migrated TCA
195 */
196 protected function migrateT3editorWizardWithEnabledByTypeConfigToColumnsOverrides(array $tca) {
197 $newTca = $tca;
198 foreach ($tca as $table => $tableDefinition) {
199 if (!isset($tableDefinition['columns']) || !is_array($tableDefinition['columns'])) {
200 continue;
201 }
202 foreach ($tableDefinition['columns'] as $fieldName => $fieldConfig) {
203 if (
204 !empty($fieldConfig['config']['type']) // type is set
205 && trim($fieldConfig['config']['type']) === 'text' // to "text"
206 && isset($fieldConfig['config']['wizards'])
207 && is_array($fieldConfig['config']['wizards']) // and there are wizards
208 ) {
209 foreach ($fieldConfig['config']['wizards'] as $wizardName => $wizardConfig) {
210 if (
211 !empty($wizardConfig['userFunc']) // a userFunc is defined
212 && trim($wizardConfig['userFunc']) === 'TYPO3\CMS\T3editor\FormWizard->main' // and set to FormWizard
213 && !empty($wizardConfig['enableByTypeConfig']) // and enableByTypeConfig is enabled
214 ) {
215 // Remove this wizard
216 unset($newTca[$table]['columns'][$fieldName]['config']['wizards'][$wizardName]);
217 // Find configured types that use this wizard
218 if (!isset($tableDefinition['types']) || !is_array($tableDefinition['types'])) {
219 // No type definition at all ... continue directly
220 continue;
221 }
222 foreach ($tableDefinition['types'] as $typeName => $typeArray) {
223 if (
224 empty($typeArray['columnsOverrides'][$fieldName]['defaultExtras'])
225 || strpos($typeArray['columnsOverrides'][$fieldName]['defaultExtras'], $wizardName) === FALSE
226 ) {
227 // Continue directly if this wizard is not enabled for given type
228 continue;
229 }
230 $defaultExtras = $typeArray['columnsOverrides'][$fieldName]['defaultExtras'];
231 $defaultExtrasArray = GeneralUtility::trimExplode(':', $defaultExtras, TRUE);
232 $newDefaultExtrasArray = array();
233 foreach ($defaultExtrasArray as $fieldExtraField) {
234 // There might be multiple enabled wizards separated by | ... split them
235 if (substr($fieldExtraField, 0, 8) === 'wizards[') {
236 $enabledWizards = substr($fieldExtraField, 8, strlen($fieldExtraField) - 8); // Cut off "wizards[
237 $enabledWizards = substr($enabledWizards, 0, strlen($enabledWizards) - 1);
238 $enabledWizardsArray = GeneralUtility::trimExplode('|', $enabledWizards, TRUE);
239 $newEnabledWizardsArray = array();
240 foreach ($enabledWizardsArray as $enabledWizardName) {
241 if ($enabledWizardName === $wizardName) {
242 // Found a columnsOverrides configuration that has this wizard enabled
243 // Force renderType = t3editor
244 $newTca[$table]['types'][$typeName]['columnsOverrides'][$fieldName]['config']['renderType'] = 't3editor';
245 // Transfer format option if given
246 if (!empty($wizardConfig['params']['format'])) {
247 $newTca[$table]['types'][$typeName]['columnsOverrides'][$fieldName]['config']['format'] = $wizardConfig['params']['format'];
248 }
249 $this->messages[] = 'Migrated t3editor wizard in TCA of table "' . $table . '" field "' . $fieldName
250 . '" to a renderType definition with columnsOverrides in type "' . $typeName . '".';
251 } else {
252 // Some other enabled wizard
253 $newEnabledWizardsArray[] = $enabledWizardName;
254 }
255 }
256 if (!empty($newEnabledWizardsArray)) {
257 $newDefaultExtrasArray[] = 'wizards[' . implode('|', $newEnabledWizardsArray) . ']';
258 }
259 } else {
260 $newDefaultExtrasArray[] = $fieldExtraField;
261 }
262 }
263 if (!empty($newDefaultExtrasArray)) {
264 $newTca[$table]['types'][$typeName]['columnsOverrides'][$fieldName]['defaultExtras'] = implode(':', $newDefaultExtrasArray);
265 } else {
266 unset($newTca[$table]['types'][$typeName]['columnsOverrides'][$fieldName]['defaultExtras']);
267 }
268 }
269 }
270 }
271 // If no wizard is left after migration, unset the whole sub array
272 if (empty($newTca[$table]['columns'][$fieldName]['config']['wizards'])) {
273 unset($newTca[$table]['columns'][$fieldName]['config']['wizards']);
274 }
275 }
276 }
277 }
278 return $newTca;
279 }
280
281 /**
282 * Migrate types showitem 'aField;aLabel;aPalette' to 'afield;aLabel, --palette--;;aPalette'
283 *
284 * Old showitem can have a syntax like:
285 * fieldName;aLabel;aPalette
286 * This way, the palette with name "aPalette" is rendered after fieldName.
287 * The migration parses this to a syntax like:
288 * fieldName;aLabel, --palette--;;paletteName
289 *
290 * @param array $tca Incoming TCA
291 * @return array Migrated TCA
292 */
293 protected function migrateShowItemAdditionalPaletteToOwnPalette(array $tca) {
294 $newTca = $tca;
295 foreach ($tca as $table => $tableDefinition) {
296 if (!isset($tableDefinition['types']) || !is_array($tableDefinition['types'])) {
297 continue;
298 }
299 foreach ($tableDefinition['types'] as $typeName => $typeArray) {
300 if (
301 !isset($typeArray['showitem'])
302 || !is_string($typeArray['showitem'])
303 || strpos($typeArray['showitem'], ';') === FALSE // no field parameters
304 ) {
305 continue;
306 }
307 $itemList = GeneralUtility::trimExplode(',', $typeArray['showitem'], TRUE);
308 $newFieldStrings = array();
309 foreach ($itemList as $fieldString) {
310 $fieldArray = GeneralUtility::trimExplode(';', $fieldString);
311 $fieldArray = array(
312 'fieldName' => isset($fieldArray[0]) ? $fieldArray[0] : '',
313 'fieldLabel' => isset($fieldArray[1]) ? $fieldArray[1] : NULL,
314 'paletteName' => isset($fieldArray[2]) ? $fieldArray[2] : NULL,
315 );
316 if ($fieldArray['fieldName'] !== '--palette--' && $fieldArray['paletteName'] !== NULL) {
317 if ($fieldArray['fieldLabel']) {
318 $fieldString = $fieldArray['fieldName'] . ';' . $fieldArray['fieldLabel'];
319 } else {
320 $fieldString = $fieldArray['fieldName'];
321 }
322 $paletteString = '--palette--;;' . $fieldArray['paletteName'];
323 $this->messages[] = 'Migrated TCA table "' . $table . '" showitem field of type "' . $typeName . '": Moved additional palette'
324 . ' with name "' . $fieldArray['paletteName'] . '" as 3rd argument of field "' . $fieldArray['fieldName']
325 . '" to an own palette. The result of this part is: "' . $fieldString . ', ' . $paletteString . '"';
326 $newFieldStrings[] = $fieldString;
327 $newFieldStrings[] = $paletteString;
328 } else {
329 $newFieldStrings[] = $fieldString;
330 }
331 }
332 $newTca[$table]['types'][$typeName]['showitem'] = implode(',', $newFieldStrings);
333 }
334 }
335 return $newTca;
336 }
337
338 /**
339 * Migrate core icons for form field wizard to new location
340 *
341 * add.gif => EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_add.gif
342 * link_popup.gif => EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_link.gif
343 * wizard_rte2.gif => EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_rte.gif
344 * wizard_table.gif => EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_table.gif
345 * edit2.gif => EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_edit.gif
346 * list.gif => EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_list.gif
347 * wizard_forms.gif => EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_forms.gif
348 *
349 * @param array $tca Incoming TCA
350 * @return array Migrated TCA
351 */
352 protected function migrateIconsForFormFieldWizardsToNewLocation($tca) {
353 $newTca = $tca;
354
355 $oldFileNames = array(
356 'add.gif',
357 'link_popup.gif',
358 'wizard_rte2.gif',
359 'wizard_table.gif',
360 'edit2.gif',
361 'list.gif',
362 'wizard_forms.gif',
363 );
364
365 $newFileLocations = array(
366 'add.gif' => 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_add.gif',
367 'link_popup.gif' => 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_link.gif',
368 'wizard_rte2.gif' => 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_rte.gif',
369 'wizard_table.gif' => 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_table.gif',
370 'edit2.gif' => 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_edit.gif',
371 'list.gif' => 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_list.gif',
372 'wizard_forms.gif' => 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_forms.gif',
373 );
374
375 foreach ($tca as $table => $tableDefinition) {
376 if (!isset($tableDefinition['columns']) || !is_array($tableDefinition['columns'])) {
377 continue;
378 }
379 foreach ($tableDefinition['columns'] as $fieldName => $fieldConfig) {
380 if (
381 isset($fieldConfig['config']['wizards'])
382 && is_array($fieldConfig['config']['wizards']) // and there are wizards
383 ) {
384 foreach ($fieldConfig['config']['wizards'] as $wizardName => $wizardConfig) {
385 if (!is_array($wizardConfig)) {
386 continue;
387 }
388
389 foreach ($wizardConfig as $option => $value) {
390 if ($option === 'icon' && in_array($value, $oldFileNames, TRUE)) {
391 $newTca[$table]['columns'][$fieldName]['config']['wizards'][$wizardName]['icon'] = $newFileLocations[$value];
392 $this->messages[] = 'Migrated icon path of wizard "' . $wizardName . '" in field "' . $fieldName . '" from TCA table "' . $table . '". New path is: ' . $newFileLocations[$value];
393 }
394 }
395 }
396 }
397 }
398 }
399
400 return $newTca;
401 }
402
403 /**
404 * Migrate file reference which starts with ext/ or sysext/ to EXT:
405 *
406 * @param array $tca Incoming TCA
407 * @return array Migrated TCA
408 */
409 protected function migrateExtAndSysextPathToEXTPath($tca) {
410 foreach ($tca as $table => &$tableDefinition) {
411 if (!isset($tableDefinition['columns']) || !is_array($tableDefinition['columns'])) {
412 continue;
413 }
414 foreach ($tableDefinition['columns'] as $fieldName => &$fieldConfig) {
415 if (
416 !empty($fieldConfig['config']['type']) // type is set
417 && trim($fieldConfig['config']['type']) === 'select' // to "select"
418 && isset($fieldConfig['config']['items'])
419 && is_array($fieldConfig['config']['items']) // and there are items
420 ) {
421 foreach ($fieldConfig['config']['items'] as &$itemConfig) {
422 // more then two values? then the third entry is the image path
423 if (!empty($itemConfig[2])) {
424 $tcaPath = implode('.', [$table, 'columns', $fieldName, 'config', 'items']);
425 $pathParts = GeneralUtility::trimExplode('/', $itemConfig[2]);
426 // remove first element (ext or sysext)
427 array_shift($pathParts);
428 $path = implode('/', $pathParts);
429 // If the path starts with ext/ or sysext/ migrate it
430 if (
431 StringUtility::beginsWith($itemConfig[2], 'ext/')
432 || StringUtility::beginsWith($itemConfig[2], 'sysext/')
433 ) {
434 $this->messages[] = '[' . $tcaPath . '] ext/ or sysext/ within the path (' . $path . ') in items array is deprecated, use EXT: reference';
435 $itemConfig[2] = 'EXT:' . $path;
436 } elseif (StringUtility::beginsWith($itemConfig[2], 'i/')) {
437 $this->messages[] = '[' . $tcaPath . '] i/ within the path (' . $path . ') in items array is deprecated, use EXT: reference';
438 $itemConfig[2] = 'EXT:t3skin/icons/gfx/' . $itemConfig[2];
439 }
440 }
441 }
442 }
443 }
444 }
445 return $tca;
446 }
447
448 /**
449 * Migrate "iconsInOptionTags" for "select" TCA fields
450 *
451 * @param array $tca Incoming TCA
452 * @return array Migrated TCA
453 */
454 protected function migrateIconsInOptionTags($tca) {
455 $newTca = $tca;
456
457 foreach ($newTca as $table => &$tableDefinition) {
458 if (!isset($tableDefinition['columns']) || !is_array($tableDefinition['columns'])) {
459 continue;
460 }
461 foreach ($tableDefinition['columns'] as $fieldName => &$fieldConfig) {
462 if (isset($fieldConfig['config']['iconsInOptionTags'])) {
463 unset($fieldConfig['config']['iconsInOptionTags']);
464 $this->messages[] = 'Configuration option "iconsInOptionTags" was removed from field "' . $fieldName . '" in TCA table "' . $table . '"';
465 }
466 }
467 }
468
469 return $newTca;
470 }
471
472 /**
473 * Migrate "iconfile" references which starts with ../ to EXT: and consisting of filename only to absolute paths in EXT:t3skin
474 *
475 * @param array $tca Incoming TCA
476 * @return array Migrated TCA
477 */
478 protected function migrateIconfileRelativePathOrFilenameOnlyToExtReference($tca) {
479 foreach ($tca as $table => &$tableDefinition) {
480 if (!isset($tableDefinition['ctrl']) || !is_array($tableDefinition['ctrl'])) {
481 continue;
482 }
483 if (!isset($tableDefinition['ctrl']['iconfile'])) {
484 continue;
485 }
486 if (StringUtility::beginsWith($tableDefinition['ctrl']['iconfile'], '../typo3conf/ext/')) {
487 $tableDefinition['ctrl']['iconfile'] = str_replace('../typo3conf/ext/', 'EXT:', $tableDefinition['ctrl']['iconfile']);
488 $tcaPath = implode('.', [$table, 'ctrl', 'iconfile']);
489 $this->messages[] = '[' . $tcaPath . '] relative path to ../typo3conf/ext/ is deprecated, use EXT: instead';
490 } elseif (strpos($tableDefinition['ctrl']['iconfile'], '/') === FALSE) {
491 $tableDefinition['ctrl']['iconfile'] = 'EXT:t3skin/icons/gfx/i/' . $tableDefinition['ctrl']['iconfile'];
492 $tcaPath = implode('.', [$table, 'ctrl', 'iconfile']);
493 $this->messages[] = '[' . $tcaPath . '] filename only is deprecated, use EXT: or absolute reference instead';
494 }
495 }
496 return $tca;
497 }
498
499 /**
500 * Migrate "type=select" with "renderMode=[tree|singlebox|checkbox]" to "renderType=[selectTree|selectSingleBox|selectCheckBox]".
501 * This migration also take care of "maxitems" settings and set "renderType=[selectSingle|selectMultipleSideBySide]" if no other
502 * renderType is already set.
503 *
504 * @param array $tca
505 * @return array
506 */
507 public function migrateSelectFieldRenderType(array $tca) {
508 $newTca = $tca;
509
510 foreach ($newTca as $table => &$tableDefinition) {
511
512 if (empty($tableDefinition['columns'])) {
513 continue;
514 }
515
516 foreach ($tableDefinition['columns'] as $columnName => &$columnDefinition) {
517 // Only handle select fields.
518 if (empty($columnDefinition['config']['type']) || $columnDefinition['config']['type'] !== 'select') {
519 continue;
520 }
521 // Do not handle field where the render type is set.
522 if (!empty($columnDefinition['config']['renderType'])) {
523 continue;
524 }
525
526 $tableColumnInfo = 'table "' . $table . '" and column "' . $columnName . '"';
527 $this->messages[] = 'Using select fields without the "renderType" setting is deprecated in ' . $tableColumnInfo;
528
529 $columnConfig = &$columnDefinition['config'];
530 if (!empty($columnConfig['renderMode'])) {
531 $this->messages[] = 'The "renderMode" setting for select fields is deprecated. Please use "renderType" instead in ' . $tableColumnInfo;
532 switch ($columnConfig['renderMode']) {
533 case 'tree':
534 $columnConfig['renderType'] = 'selectTree';
535 break;
536 case 'singlebox':
537 $columnConfig['renderType'] = 'selectSingleBox';
538 break;
539 case 'checkbox':
540 $columnConfig['renderType'] = 'selectCheckBox';
541 break;
542 default:
543 $this->messages[] = 'The render mode ' . $columnConfig['renderMode'] . ' is invalid for the select field in ' . $tableColumnInfo;
544 }
545 continue;
546 }
547
548 $maxItems = !empty($columnConfig['maxitems']) ? (int)$columnConfig['maxitems'] : 1;
549 if ($maxItems <= 1) {
550 $columnConfig['renderType'] = 'selectSingle';
551 } else {
552 $columnConfig['renderType'] = 'selectMultipleSideBySide';
553 }
554 }
555 }
556
557 return $newTca;
558 }
559 }