Skip to content

Commit

Permalink
[TASK] migrate plugin subtype "list_type"
Browse files Browse the repository at this point in the history
  • Loading branch information
dkd-kaehm committed Oct 8, 2024
1 parent 26e38f8 commit 8591d3e
Show file tree
Hide file tree
Showing 15 changed files with 111 additions and 62 deletions.
11 changes: 7 additions & 4 deletions Classes/Backend/SettingsPreviewOnPlugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __invoke(PageContentPreviewRenderingEvent $event): void
$this->pluginsTtContentRecord = $event->getRecord();
if (
$event->getTable() !== 'tt_content'
|| !str_starts_with($this->pluginsTtContentRecord['list_type'], 'solr_pi_')
|| !str_starts_with($this->pluginsTtContentRecord['CType'], 'solr_pi_')
) {
return;
}
Expand Down Expand Up @@ -152,14 +152,17 @@ protected function getPluginLabel(): string
$label = BackendUtility::getLabelFromItemListMerged(
$this->pluginsTtContentRecord['pid'],
'tt_content',
'list_type',
$this->pluginsTtContentRecord['list_type'],
'CType',
$this->pluginsTtContentRecord['CType'],
$this->pluginsTtContentRecord
);
if (!empty($label)) {
$label = $this->getLanguageService()->sL($label);
} else {
$label = sprintf($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.noMatchingValue'), $this->pluginsTtContentRecord['list_type']);
$label = sprintf(
$this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.noMatchingValue'),
$this->pluginsTtContentRecord['CType']
);
}

return $label;
Expand Down
48 changes: 48 additions & 0 deletions Classes/Updates/SolrSearchCTypeMigration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?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 ApacheSolrForTypo3\Solr\Updates;

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

/**
* Migrates Plugin subtypes to content elements.
* See: https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/13.4/Deprecation-105076-PluginContentElementAndPluginSubTypes.html#deprecation-105076-plugin-content-element-and-plugin-sub-types
*/
#[UpgradeWizard('solrSearchCTypeMigration')]
final class SolrSearchCTypeMigration extends AbstractListTypeToCTypeUpdate
{
protected function getListTypeToCTypeMapping(): array
{
return [
'solr_pi_results' => 'solr_pi_results',
'solr_pi_search' => 'solr_pi_search',
'solr_pi_results_search' => 'solr_pi_results_search',
];
}

public function getTitle(): string
{
return 'Migrate "Apache Solr Search" plugins to content elements.';
}

public function getDescription(): string
{
return 'The "Apache Solr Search" plugins are now registered as content element. Update migrates existing records and backend user permissions.';
}
}
49 changes: 24 additions & 25 deletions Configuration/TCA/Overrides/tt_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,43 @@

defined('TYPO3') or die('Access denied.');

// Add tt_content search group
$GLOBALS['TCA']['tt_content']['columns']['CType']['config']['itemGroups']['search'] = 'LLL:EXT:solr/Resources/Private/Language/locallang.xlf:plugin_results';

// Register the plugins
$pluginSignature = 'solr_pi_search';
ExtensionUtility::registerPlugin(
$pluginSearchSignature = ExtensionUtility::registerPlugin(
'solr',
'pi_search',
'LLL:EXT:solr/Resources/Private/Language/locallang.xlf:tt_content.list_type_pi_search'
'LLL:EXT:solr/Resources/Private/Language/locallang.xlf:tt_content.CType_pi_search',
'extensions-solr-plugin-contentelement',
'search'
);
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist'][$pluginSignature]
= 'layout,select_key,pages,recursive';
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature]
= 'pi_flexform';
$GLOBALS['TCA']['tt_content']['types'][$pluginSearchSignature]['showitem'] = 'pi_flexform';
ExtensionManagementUtility::addPiFlexFormValue(
$pluginSignature,
'FILE:EXT:solr/Configuration/FlexForms/Form.xml'
'*',
'FILE:EXT:solr/Configuration/FlexForms/Form.xml',
$pluginSearchSignature
);

$pluginSignature = 'solr_pi_frequentlysearched';
ExtensionUtility::registerPlugin(
$pluginFrequentlySearchedSignature = ExtensionUtility::registerPlugin(
'solr',
'pi_frequentlySearched',
'LLL:EXT:solr/Resources/Private/Language/locallang.xlf:tt_content.list_type_pi_frequentsearches'
'LLL:EXT:solr/Resources/Private/Language/locallang.xlf:tt_content.CType_pi_frequentsearches',
'extensions-solr-plugin-contentelement',
'search'
);
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist'][$pluginSignature]
= 'layout,select_key,pages,recursive';
$GLOBALS['TCA']['tt_content']['types'][$pluginFrequentlySearchedSignature]['showitem'] = 'pi_flexform';

$pluginSignature = 'solr_pi_results';
ExtensionUtility::registerPlugin(
$pluginResultsSignature = ExtensionUtility::registerPlugin(
'solr',
'pi_results',
'LLL:EXT:solr/Resources/Private/Language/locallang.xlf:tt_content.list_type_pi_results'
'LLL:EXT:solr/Resources/Private/Language/locallang.xlf:tt_content.CType_pi_results',
'extensions-solr-plugin-contentelement',
'search'
);

$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist'][$pluginSignature]
= 'layout,select_key,pages,recursive';
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature]
= 'pi_flexform';

$GLOBALS['TCA']['tt_content']['types'][$pluginResultsSignature]['showitem'] = 'pi_flexform';
ExtensionManagementUtility::addPiFlexFormValue(
$pluginSignature,
'FILE:EXT:solr/Configuration/FlexForms/Results.xml'
'*',
'FILE:EXT:solr/Configuration/FlexForms/Results.xml',
$pluginResultsSignature
);
15 changes: 3 additions & 12 deletions Configuration/page.tsconfig
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
mod.wizards.newContentElement.wizardItems.plugins {
elements {
tx_solr_results {
iconIdentifier = extensions-solr-plugin-contentelement
title = LLL:EXT:solr/Resources/Private/Language/locallang.xlf:plugin_results
description = LLL:EXT:solr/Resources/Private/Language/locallang.xlf:plugin_results_description
tt_content_defValues {
CType = list
list_type = solr_pi_results
}
}
}
mod.wizards.newContentElement.wizardItems {
# CATEGORIES
search.header = LLL:EXT:solr/Resources/Private/Language/locallang.xlf:plugin_results
}
Binary file modified Documentation/Images/Backend/plugin_instances.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
6 changes: 3 additions & 3 deletions Resources/Private/Language/de.locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@
<target state="final">Letzte</target></trans-unit>
<!-- From locallang.xlf -->
<!-- From locallang_db.xlf -->
<trans-unit id="tt_content.list_type_pi_frequentsearches" xml:space="preserve" approved="yes">
<trans-unit id="tt_content.CType_pi_frequentsearches" xml:space="preserve" approved="yes">
<source>Search: Frequent Searches</source>
<target state="final">Suche: Häufige Suchen</target></trans-unit>
<trans-unit id="tt_content.list_type_pi_results" xml:space="preserve" approved="yes">
<trans-unit id="tt_content.CType_pi_results" xml:space="preserve" approved="yes">
<source>Search: Form, Result, Additional Components</source>
<target state="final">Suche: Formular, Ergebnisse, weitere Komponenten</target></trans-unit>
<trans-unit id="tt_content.list_type_pi_search" xml:space="preserve" approved="yes">
<trans-unit id="tt_content.CType_pi_search" xml:space="preserve" approved="yes">
<source>Search: Form only</source>
<target state="final">Suche: Nur Suchformular</target></trans-unit>
</body>
Expand Down
8 changes: 4 additions & 4 deletions Resources/Private/Language/dk.locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,18 @@
</trans-unit>

<!-- From locallang_db.xlf -->
<trans-unit id="tt_content.list_type_pi_frequentsearches" xml:space="preserve" approved="yes">
<trans-unit id="tt_content.CType_pi_frequentsearches" xml:space="preserve" approved="yes">
<source>Search: Frequent Searches</source>
<target></target>
</trans-unit>
<trans-unit id="tt_content.list_type_pi_results" xml:space="preserve" approved="yes">
<trans-unit id="tt_content.CType_pi_results" xml:space="preserve" approved="yes">
<source>Search: Form, Result, Additional Components</source>
<target>Søg: Søgeformular, Resultater, Yderligere komponenter</target>
</trans-unit>
<trans-unit id="tt_content.list_type_pi_search" xml:space="preserve" approved="yes">
<trans-unit id="tt_content.CType_pi_search" xml:space="preserve" approved="yes">
<source>Search: Form only</source>
<target></target>
</trans-unit>
</body>
</file>
</xliff>
</xliff>
6 changes: 3 additions & 3 deletions Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,13 @@
</trans-unit>

<!-- From locallang_db.xlf -->
<trans-unit id="tt_content.list_type_pi_frequentsearches" xml:space="preserve">
<trans-unit id="tt_content.CType_pi_frequentsearches" xml:space="preserve">
<source>Search: Frequent Searches</source>
</trans-unit>
<trans-unit id="tt_content.list_type_pi_results" xml:space="preserve">
<trans-unit id="tt_content.CType_pi_results" xml:space="preserve">
<source>Search: Form, Result, Additional Components</source>
</trans-unit>
<trans-unit id="tt_content.list_type_pi_search" xml:space="preserve">
<trans-unit id="tt_content.CType_pi_search" xml:space="preserve">
<source>Search: Form only</source>
</trans-unit>

Expand Down
2 changes: 1 addition & 1 deletion Tests/Integration/Backend/SettingsPreviewOnPluginsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function printsPreviewOnExtSolrPluginsCorrectly(): void
[
'pid' => 11,
'pi_flexform' => 'provided via mock return value $this->flexFormArray',
'list_type' => 'solr_pi_results',
'CType' => 'solr_pi_results',
'hidden' => 0,
]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
,"uid","pid","is_siteroot","doktype","slug","title","subtitle"
,2022,1,0,1,"/search","Search","Apache Solr for TYPO3 search page"
"tt_content",
,"uid","pid","colPos","frame_class","CType","list_type","sectionIndex"
,2022,2022,0,"default","list","solr_pi_results",1
,"uid","pid","colPos","frame_class","CType","sectionIndex"
,2022,2022,0,"default","solr_pi_results",1
4 changes: 2 additions & 2 deletions Tests/Integration/Controller/SearchControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ public function formActionIsRenderingTheForm(): void
$connection = $this->getConnectionPool()->getConnectionForTable('tt_content');
$connection->update(
'tt_content',
['list_type' => 'solr_pi_search'],
['CType' => 'solr_pi_search'],
['uid' => 2022]
);

Expand All @@ -1259,7 +1259,7 @@ public function searchingAndRenderingFrequentSearchesIsShowingTheTermAsFrequentS
$this->getConnectionPool()->getConnectionForTable('tt_content')
->update(
'tt_content',
['list_type' => 'solr_pi_frequentlysearched'],
['CType' => 'solr_pi_frequentlysearched'],
['uid' => 2022]
);

Expand Down
2 changes: 1 addition & 1 deletion Tests/Unit/Backend/SettingsPreviewOnPluginsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function doesNotPrintPreviewOnNonExtSolrPlugins(): void
$this->getFakePageContentPreviewRenderingEvent(
'tt_content',
[
'list_type' => 'some_other_CE',
'CType' => 'some_other_CE',
]
)
);
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
"ext-simplexml": "*",
"solarium/solarium": "6.3.5",
"typo3/cms-backend": "*",
"typo3/cms-core": "^v13.1",
"typo3/cms-core": "^v13.4",
"typo3/cms-extbase": "*",
"typo3/cms-fluid": "*",
"typo3/cms-frontend": "*",
"typo3/cms-install": "*",
"typo3/cms-reports": "*",
"typo3/cms-scheduler": "*",
"typo3/cms-tstemplate": "*"
Expand Down
15 changes: 11 additions & 4 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,20 @@
],
[
SearchController::class => 'results',
]
],
ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT
);

ExtensionUtility::configurePlugin(
'Solr',
'pi_search',
[
SearchController::class => 'form',
]
],
[

],
ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT
);

ExtensionUtility::configurePlugin(
Expand All @@ -198,7 +203,8 @@
],
[
SearchController::class => 'frequentlySearched',
]
],
ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT
);

ExtensionUtility::configurePlugin(
Expand All @@ -209,7 +215,8 @@
],
[
SuggestController::class => 'suggest',
]
],
ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT
);

// register the Fluid namespace 'solr' globally
Expand Down

0 comments on commit 8591d3e

Please sign in to comment.