Skip to content

Commit

Permalink
[TASK] Change extension plugins registration
Browse files Browse the repository at this point in the history
Plugins are now registered as CType from list_type.
Migration is provided.
  • Loading branch information
garbast committed Oct 31, 2024
1 parent 1d4839c commit 72d7dac
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 61 deletions.
50 changes: 50 additions & 0 deletions Classes/Updates/StoreFinderCTypeMigration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

declare(strict_types=1);

/*
* 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!
*/

namespace Evoweb\StoreFinder\Updates;

use TYPO3\CMS\Install\Attribute\UpgradeWizard;
use TYPO3\CMS\Install\Updates\AbstractListTypeToCTypeUpdate;

/**
* @internal This class is only meant to be used within EXT:install.
*/
#[UpgradeWizard('storeFinderCTypeMigration')]
final class StoreFinderCTypeMigration extends AbstractListTypeToCTypeUpdate
{
protected function getListTypeToCTypeMapping(): array
{
return [
'storefinder_map' => 'storefinder_map',
'storefinder_cached' => 'storefinder_cached',
'storefinder_show' => 'storefinder_show',
];
}

public function getTitle(): string
{
return 'Migrate "Store Finder" plugins to content elements.';
}

public function getDescription(): string
{
return '
The "Store Finder" plugin is now registered as content element. Update migrates existing
records and backend user permissions.
';
}
}
118 changes: 77 additions & 41 deletions Configuration/TCA/Overrides/tt_content.php
Original file line number Diff line number Diff line change
@@ -1,45 +1,81 @@
<?php

declare(strict_types=1);

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;

defined('TYPO3') or die();

$pluginSignature = 'storefinder_map';
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist'][$pluginSignature] = 'layout, select_key';
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
$pluginSignature,
'FILE:EXT:store_finder/Configuration/FlexForms/flexform_mapWithSearch.xml'
);

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'store_finder',
'Map',
'LLL:EXT:store_finder/Resources/Private/Language/locallang_be.xlf:tt_content.list_type_map'
);

$pluginSignature = 'storefinder_cached';
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist'][$pluginSignature] = 'layout, select_key';
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
$pluginSignature,
'FILE:EXT:store_finder/Configuration/FlexForms/flexform_mapWithSearch.xml'
);

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'store_finder',
'Cached',
'LLL:EXT:store_finder/Resources/Private/Language/locallang_be.xlf:tt_content.list_type_cached'
);

$pluginSignature = 'storefinder_show';
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist'][$pluginSignature] = 'layout, select_key';
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
$pluginSignature,
'FILE:EXT:store_finder/Configuration/FlexForms/flexform_singleLocation.xml'
);

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'store_finder',
'Show',
'LLL:EXT:store_finder/Resources/Private/Language/locallang_be.xlf:tt_content.list_type_show'
);
(static function () {
$languageFile = 'LLL:EXT:store_finder/Resources/Private/Language/locallang_be.xlf:';
$GLOBALS['TCA']['tt_content']['palettes']['storefinder-frames'] = [
'label' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.frames',
'showitem' => '
frame_class;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:frame_class_formlabel,
space_before_class;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:space_before_class_formlabel,
space_after_class;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:space_after_class_formlabel
'
];

$showItems = '
--palette--;;general,
--palette--;;headers,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:plugin,
pi_flexform,
pages;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:pages.ALT.list_formlabel,
recursive,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:appearance,
--palette--;;storefinder-frames,
--palette--;;appearanceLinks,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,
categories,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,
--palette--;;language,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
--palette--;;hidden,
--palette--;;access,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:notes,
rowDescription,
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended
';

ExtensionUtility::registerPlugin(
'store_finder',
'Map',
$languageFile . 'tt_content.list_type_map'
);
$GLOBALS['TCA']['tt_content']['types']['storefinder_map']['showitem'] = $showItems;

ExtensionManagementUtility::addPiFlexFormValue(
'*',
'FILE:EXT:store_finder/Configuration/FlexForms/flexform_mapWithSearch.xml',
'storefinder_map'
);

ExtensionUtility::registerPlugin(
'store_finder',
'Cached',
$languageFile . 'tt_content.list_type_cached'
);
$GLOBALS['TCA']['tt_content']['types']['storefinder_cached']['showitem'] = $showItems;

ExtensionManagementUtility::addPiFlexFormValue(
'*',
'FILE:EXT:store_finder/Configuration/FlexForms/flexform_mapWithSearch.xml',
'storefinder_cached'
);

ExtensionUtility::registerPlugin(
'store_finder',
'Show',
$languageFile . 'tt_content.list_type_show'
);
$GLOBALS['TCA']['tt_content']['types']['storefinder_show']['showitem'] = $showItems;

ExtensionManagementUtility::addPiFlexFormValue(
'*',
'FILE:EXT:store_finder/Configuration/FlexForms/flexform_singleLocation.xml',
'storefinder_show'
);
})();
11 changes: 4 additions & 7 deletions Configuration/TSconfig/NewContentElementWizard.tsconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ mod.wizards.newContentElement.wizardItems.store_finder {
title = LLL:EXT:store_finder/Resources/Private/Language/locallang_be.xlf:pi1_title_map
description = LLL:EXT:store_finder/Resources/Private/Language/locallang_be.xlf:pi1_description_map
tt_content_defValues {
CType = list
list_type = storefinder_map
CType = storefinder_map
}
}

Expand All @@ -17,8 +16,7 @@ mod.wizards.newContentElement.wizardItems.store_finder {
title = LLL:EXT:store_finder/Resources/Private/Language/locallang_be.xlf:pi1_title_cached
description = LLL:EXT:store_finder/Resources/Private/Language/locallang_be.xlf:pi1_description_cached
tt_content_defValues {
CType = list
list_type = storefinder_cached
CType = storefinder_cached
}
}

Expand All @@ -27,16 +25,15 @@ mod.wizards.newContentElement.wizardItems.store_finder {
title = LLL:EXT:store_finder/Resources/Private/Language/locallang_be.xlf:pi1_title_show
description = LLL:EXT:store_finder/Resources/Private/Language/locallang_be.xlf:pi1_description_show
tt_content_defValues {
CType = list
list_type = storefinder_show
CType = storefinder_show
}
}
}

show = *
}

mod.web_layout.tt_content.preview.list {
mod.web_layout.tt_content.preview {
storefinder_map = EXT:store_finder/Resources/Private/Templates/Preview/Map.html
storefinder_cached = EXT:store_finder/Resources/Private/Templates/Preview/Map.html
storefinder_show = EXT:store_finder/Resources/Private/Templates/Preview/Show.html
Expand Down
29 changes: 16 additions & 13 deletions ext_localconf.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

defined('TYPO3') or die();

use Evoweb\StoreFinder\Controller\MapController;
Expand All @@ -9,17 +11,17 @@
use TYPO3\CMS\Backend\Form\FormDataProvider\TcaSelectItems as TcaSelectItems;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;

call_user_func(function () {
(static function () {
$cacheConfigurations = & $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'];
if (!is_array($cacheConfigurations['store_finder_coordinate_cache'] ?? null)) {
$cacheConfigurations['store_finder_coordinate_cache'] = [
'groups' => ['system'],
'groups' => [ 'system' ],
];
}

if (!is_array($cacheConfigurations['store_finder_middleware_cache'] ?? null)) {
$cacheConfigurations['store_finder_middleware_cache'] = [
'groups' => ['pages'],
'groups' => [ 'pages' ],
];
}

Expand All @@ -37,29 +39,30 @@
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord'][
LocationCountryItems::class
] = [
'depends' => [
TcaSelectItems::class,
]
'depends' => [ TcaSelectItems::class ]
];

ExtensionUtility::configurePlugin(
'StoreFinder',
'Map',
[MapController::class => 'map, search, show'],
[MapController::class => 'map, search, show']
[ MapController::class => 'map, search, show' ],
[ MapController::class => 'map, search, show' ],
ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT
);

ExtensionUtility::configurePlugin(
'StoreFinder',
'Cached',
[MapController::class => 'cachedMap, map, search, show'],
[MapController::class => 'map, search, show']
[ MapController::class => 'cachedMap, map, search, show' ],
[ MapController::class => 'map, search, show' ],
ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT
);

ExtensionUtility::configurePlugin(
'StoreFinder',
'Show',
[MapController::class => 'show'],
[MapController::class => 'show']
[ MapController::class => 'show' ],
[ MapController::class => 'show' ],
ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT
);
});
})();

0 comments on commit 72d7dac

Please sign in to comment.