Skip to content

Commit

Permalink
[!!!][TASK] Migrate plugins to content elements
Browse files Browse the repository at this point in the history
All existing plugins have been migrated to content elements.
The included update wizard must be executed in order to
migrate existing plugins and permissions.

Closes #1189
  • Loading branch information
derhansen committed Oct 8, 2024
1 parent 3f68c85 commit 0f1d7a3
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 65 deletions.
4 changes: 2 additions & 2 deletions Classes/EventListener/AbstractPluginPreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(
*/
protected function getPluginName(array $record): string
{
$pluginId = str_replace('sfeventmgt_', '', $record['list_type']);
$pluginId = str_replace('sfeventmgt_', '', $record['CType']);
return htmlspecialchars($this->getLanguageService()->sL(self::LLPATH . 'plugin.' . $pluginId . '.title'));
}

Expand Down Expand Up @@ -138,7 +138,7 @@ protected function setOverrideDemandSettings(array &$data, array $flexFormData,
$text = '';

// Check if plugin action is "calendar" and if so, show warning that calendar action will not work
if ($record['list_type'] === 'sfeventmgt_pieventcalendar') {
if ($record['CType'] === 'sfeventmgt_pieventcalendar') {
$text .= ' <span class="badge badge-danger ms-1">' .
htmlspecialchars($this->getLanguageService()->sL(self::LLPATH . 'flexforms_general.pluginCalendarMisonfiguration')) . '</span>';
}
Expand Down
3 changes: 1 addition & 2 deletions Classes/EventListener/PieventContentPreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ final class PieventContentPreview extends AbstractPluginPreview
public function __invoke(PageContentPreviewRenderingEvent $event): void
{
if ($event->getTable() !== 'tt_content' ||
$event->getRecordType() !== 'list' ||
!in_array($event->getRecord()['list_type'], $this->configuredPlugins, true)
!in_array($event->getRecordType(), $this->configuredPlugins, true)
) {
return;
}
Expand Down
3 changes: 1 addition & 2 deletions Classes/EventListener/PipaymentContentPreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ final class PipaymentContentPreview extends AbstractPluginPreview
public function __invoke(PageContentPreviewRenderingEvent $event): void
{
if ($event->getTable() !== 'tt_content' ||
$event->getRecordType() !== 'list' ||
$event->getRecord()['list_type'] !== 'sfeventmgt_pipayment'
$event->getRecordType() !== 'sfeventmgt_pipayment'
) {
return;
}
Expand Down
3 changes: 1 addition & 2 deletions Classes/EventListener/PiuserregContentPreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ final class PiuserregContentPreview extends AbstractPluginPreview
public function __invoke(PageContentPreviewRenderingEvent $event): void
{
if ($event->getTable() !== 'tt_content' ||
$event->getRecordType() !== 'list' ||
$event->getRecord()['list_type'] !== 'sfeventmgt_piuserreg'
$event->getRecordType() !== 'sfeventmgt_piuserreg'
) {
return;
}
Expand Down
21 changes: 10 additions & 11 deletions Classes/Hooks/DataHandlerHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,19 @@ public function clearCachePostProc(array $params): void
* Structure of the checkFields array:
*
* array('sheet' => array('field1', 'field2'));
*
* @param string $status
* @param string $table
* @param string $id
* @param array $fieldArray
* @param DataHandler $dataHandler
*/
public function processDatamap_postProcessFieldArray($status, $table, $id, &$fieldArray, &$dataHandler): void
{
public function processDatamap_postProcessFieldArray(
string $status,
string $table,
string|int $id,
array &$fieldArray,
DataHandler $dataHandler
): void {
if ($table === 'tt_content' &&
($status === 'update' || $status === 'new') &&
isset($fieldArray['pi_flexform']) &&
$dataHandler->checkValue_currentRecord['CType'] === 'list' &&
in_array(
$dataHandler->checkValue_currentRecord['list_type'],
$dataHandler->checkValue_currentRecord['CType'],
[
'sfeventmgt_pieventlist',
'sfeventmgt_pieventdetail',
Expand All @@ -73,7 +71,8 @@ public function processDatamap_postProcessFieldArray($status, $table, $id, &$fie
'sfeventmgt_pieventcalendar',
'sfeventmgt_piuserreg',
'sfeventmgt_pipayment',
]
],
true
)
) {
$checkFields = [
Expand Down
42 changes: 42 additions & 0 deletions Classes/Updates/PluginToContentElementUpdater.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Extension "sf_event_mgt" for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*/

namespace DERHANSEN\SfEventMgt\Updates;

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

#[UpgradeWizard('sfEventMgtPluginToContentElementUpdate')]
class PluginToContentElementUpdater extends AbstractListTypeToCTypeUpdate
{
protected function getListTypeToCTypeMapping(): array
{
return [
'sfeventmgt_pieventlist' => 'sfeventmgt_pieventlist',
'sfeventmgt_pieventdetail' => 'sfeventmgt_pieventdetail',
'sfeventmgt_pieventregistration' => 'sfeventmgt_pieventregistration',
'sfeventmgt_pieventsearch' => 'sfeventmgt_pieventsearch',
'sfeventmgt_pieventcalendar' => 'sfeventmgt_pieventcalendar',
'sfeventmgt_piuserreg' => 'sfeventmgt_piuserreg',
'sfeventmgt_pipayment' => 'sfeventmgt_pipayment',
];
}

public function getTitle(): string
{
return 'ext:sf_event_mgt: Migrate plugins to content elements';
}

public function getDescription(): string
{
return 'Migrates existing plugin records and backend user permissions used by ext:sf_event_mgt.';
}
}
36 changes: 27 additions & 9 deletions Configuration/TCA/Overrides/tt_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;

/**
* Add new select group for list_type
* Add new select group for content element
*/
ExtensionManagementUtility::addTcaSelectItemGroup(
'tt_content',
'list_type',
'CType',
'sf_event_mgt',
'LLL:EXT:sf_event_mgt/Resources/Private/Language/locallang_be.xlf:CType.div.plugingroup',
'after:default'
Expand Down Expand Up @@ -44,7 +44,7 @@
];

foreach ($plugins as $pluginName => $pluginConfig) {
$signature = 'sfeventmgt_' . strtolower($pluginName);
$contentTypeName = 'sfeventmgt_' . strtolower($pluginName);

// Register plugin
ExtensionUtility::registerPlugin(
Expand All @@ -55,17 +55,35 @@
'sf_event_mgt'
);

// Remove unused fields
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist'][$signature] = 'layout,recursive,select_key,pages';

// Register flexform if required
if (($pluginConfig['flexForm'] ?? null)) {
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$signature] = 'pi_flexform';
ExtensionManagementUtility::addPiFlexFormValue(
$signature,
'FILE:EXT:sf_event_mgt/Configuration/FlexForms/' . $pluginConfig['flexForm']
'*',
'FILE:EXT:sf_event_mgt/Configuration/FlexForms/' . $pluginConfig['flexForm'],
$contentTypeName
);
}

$GLOBALS['TCA']['tt_content']['types'][$contentTypeName]['showitem'] = '
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
--palette--;;general,
--palette--;;headers,
--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.plugin,
pi_flexform,
--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance,
--palette--;;frames,
--palette--;;appearanceLinks,
--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:categories,
categories,
--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,
';
}

/**
Expand Down
21 changes: 7 additions & 14 deletions Configuration/TSConfig/Mod/Wizards/ContentElement.tsconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,55 @@ mod.wizards.newContentElement.wizardItems.ext-sfeventmgt {
title = LLL:EXT:sf_event_mgt/Resources/Private/Language/locallang_be.xlf:plugin.pieventlist.title
description = LLL:EXT:sf_event_mgt/Resources/Private/Language/locallang_be.xlf:plugin.pieventlist.description
tt_content_defValues {
CType = list
list_type = sfeventmgt_pieventlist
CType = sfeventmgt_pieventlist
}
}
pieventdetail {
iconIdentifier = ext-sfeventmgt-default
title = LLL:EXT:sf_event_mgt/Resources/Private/Language/locallang_be.xlf:plugin.pieventdetail.title
description = LLL:EXT:sf_event_mgt/Resources/Private/Language/locallang_be.xlf:plugin.pieventdetail.description
tt_content_defValues {
CType = list
list_type = sfeventmgt_pieventdetail
CType = sfeventmgt_pieventdetail
}
}
pieventregistration {
iconIdentifier = ext-sfeventmgt-default
title = LLL:EXT:sf_event_mgt/Resources/Private/Language/locallang_be.xlf:plugin.pieventregistration.title
description = LLL:EXT:sf_event_mgt/Resources/Private/Language/locallang_be.xlf:plugin.pieventregistration.description
tt_content_defValues {
CType = list
list_type = sfeventmgt_pieventregistration
CType = sfeventmgt_pieventregistration
}
}
pieventcalendar {
iconIdentifier = ext-sfeventmgt-default
title = LLL:EXT:sf_event_mgt/Resources/Private/Language/locallang_be.xlf:plugin.pieventcalendar.title
description = LLL:EXT:sf_event_mgt/Resources/Private/Language/locallang_be.xlf:plugin.pieventcalendar.description
tt_content_defValues {
CType = list
list_type = sfeventmgt_pieventcalendar
CType = sfeventmgt_pieventcalendar
}
}
pieventsearch {
iconIdentifier = ext-sfeventmgt-default
title = LLL:EXT:sf_event_mgt/Resources/Private/Language/locallang_be.xlf:plugin.pieventsearch.title
description = LLL:EXT:sf_event_mgt/Resources/Private/Language/locallang_be.xlf:plugin.pieventsearch.description
tt_content_defValues {
CType = list
list_type = sfeventmgt_pieventsearch
CType = sfeventmgt_pieventsearch
}
}
pipayment {
iconIdentifier = ext-sfeventmgt-default
title = LLL:EXT:sf_event_mgt/Resources/Private/Language/locallang_be.xlf:plugin.pipayment.title
description = LLL:EXT:sf_event_mgt/Resources/Private/Language/locallang_be.xlf:plugin.pipayment.description
tt_content_defValues {
CType = list
list_type = sfeventmgt_pipayment
CType = sfeventmgt_pipayment
}
}
piuserreg {
iconIdentifier = ext-sfeventmgt-default
title = LLL:EXT:sf_event_mgt/Resources/Private/Language/locallang_be.xlf:plugin.piuserreg.title
description = LLL:EXT:sf_event_mgt/Resources/Private/Language/locallang_be.xlf:plugin.piuserreg.description
tt_content_defValues {
CType = list
list_type = sfeventmgt_piuserreg
CType = sfeventmgt_piuserreg
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions Documentation/Reference/BreakingChanges/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Breaking Changes
~~~~~
This version contains several breaking changes. The most relevant changes are:

* All plugins have been migrated to content elements. It is required to execute
the included update wizard. Possible content element restrictions in backend
layouts or container elements must be adapted manually.

* All existing links sent via email to registered users (e.g. confirmation- or
cancellation links) have become **invalid**.

Expand Down
Loading

0 comments on commit 0f1d7a3

Please sign in to comment.