Migration from subtypes to types
Table of contents
Migrate plugins with FlexForms added via subtypes_addlist
If you used plugins with the now deprecated subtypes, you probably used subtypes_addlist to display a FlexForm for configuration purposes.
Migrate by adding the field pi_ with the utility method
Extension
add instead. You also have to change the parameters used for
method add:
$pluginSignature = ExtensionUtility::registerPlugin(
'my_extension',
'Pi1',
'List of blogs',
);
-$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature]
- = 'pi_flexform';
+ExtensionManagementUtility::addToAllTCAtypes(
+ 'tt_content',
+ '--div--;Configuration,pi_flexform,pages,recursive,',
+ $pluginSignature,
+ 'after:subheader',
+);
ExtensionManagementUtility::addPiFlexFormValue(
- $pluginSignature,
+ '*',
'FILE:EXT:my_extension/Configuration/FlexForms/PluginSettings.xml',
+ $pluginSignature,
);
The fields pages and recursive used to be added
automatically to plugins when using the now outdated subtype "list_type".
Therefore they have to be added manually when doing the migration.
Migrate plugins with fields removed via subtypes_excludelist
Many extension author used the now deprecated option subtypes_excludelist to hide these automatically added fields.
The same effect can now be used by simply not adding the fields in the first place:
$pluginSignature = ExtensionUtility::registerPlugin(
'my_extension',
'Pi1',
'List of blogs',
);
-$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist'][$pluginSignature]
- = 'pages,recursive';
If any other fields have been removed with this method you can only remove them by overriding $GLOBALS['TCA']['tt_content']['types'][$pluginSignature]['showitem'] or via page TSconfig.
Migrate custom tables using subtypes
Replace any subtype_value_field configuration with dedicated record types. Please also consider migrating corresponding subtypes_addlist and subtypes_excludelist definitions accordingly.
In the following example, events of table tx_ used the
subtype field event_ to show the field stream_ instead of
location for online events. After the migration, online events are a
record type of their own with their own showitem list:
return [
'ctrl' => [
'type' => 'type',
// ...
],
'columns' => [
'type' => [
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['label' => 'Event', 'value' => 'event'],
+ ['label' => 'Online event', 'value' => 'online_event'],
],
],
],
- 'event_format' => [
- 'config' => [
- 'type' => 'select',
- 'renderType' => 'selectSingle',
- 'items' => [
- ['label' => 'On site', 'value' => 'on_site'],
- ['label' => 'Online', 'value' => 'online'],
- ],
- ],
- ],
// ...
],
'types' => [
'event' => [
- 'showitem' => 'type, event_format, title, location',
- 'subtype_value_field' => 'event_format',
- 'subtypes_addlist' => [
- 'online' => 'stream_url',
- ],
- 'subtypes_excludelist' => [
- 'online' => 'location',
- ],
+ 'showitem' => 'type, title, location',
+ ],
+ 'online_event' => [
+ 'showitem' => 'type, stream_url, title',
],
],
];
subtypes_ inserted its fields directly after the subtype field,
so stream_ takes the place of event_ in the new showitem
list.
Existing records keep their old values. Update the type field of records
that used the subtype, here all events with event_ set to
online, to the new record type online_. Then drop the subtype
column.
Migration: PreviewRenderer for subtypes
When migrating a plugin with a PreviewRenderer from list_ registration to
its own CType change the PreviewRenderer configuration to the record type as
well:
$pluginSignature = ExtensionUtility::registerPlugin(
'my_extension',
'Pi1',
'List of blogs',
);
-$GLOBALS['TCA']['tt_content']['types']['list_type']['previewRenderer'][$pluginSignature]
- = \MyVendor\MyExtension\Preview\PreviewRenderer::class;
+$GLOBALS['TCA']['tt_content']['types'][$pluginSignature]['previewRenderer']
+ = \MyVendor\MyExtension\Preview\PreviewRenderer::class;