mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2024-11-10 00:56:12 +01:00

[TASK] Replace switchable controller actions (#575)

This commit is contained in:
Łukasz Uznański 2022-09-27 11:53:43 +02:00 committed by GitHub
parent 9c3e8abd24
commit 2484f6d8ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 32 additions and 69 deletions

View file

@ -8,6 +8,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
### Added
### Changed
- Replace switchable controller actions with separate plugins (#575)
### Deprecated

View file

@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<T3DataStructure>
<sheets>
<general>
<ROOT>
<TCEforms>
<!--
The sheet title will not be visible in the BE. Still, the XML element needs to be present to
avoid a crash in the BE.
-->
<sheetTitle/>
</TCEforms>
<type>array</type>
<el>
<switchableControllerActions>
<TCEforms>
<label>LLL:EXT:tea/Resources/Private/Language/locallang.xlf:plugin.tea.view</label>
<onChange>reload</onChange>
<config>
<type>select</type>
<renderType>selectSingle</renderType>
<items type="array">
<numIndex index="1" type="array">
<numIndex index="0">LLL:EXT:tea/Resources/Private/Language/locallang.xlf:plugin.tea.index</numIndex>
<numIndex index="1">Tea->index</numIndex>
</numIndex>
<numIndex index="2" type="array">
<numIndex index="0">LLL:EXT:tea/Resources/Private/Language/locallang.xlf:plugin.tea.show</numIndex>
<numIndex index="1">Tea->show</numIndex>
</numIndex>
</items>
</config>
</TCEforms>
</switchableControllerActions>
</el>
</ROOT>
</general>
</sheets>
</T3DataStructure>

View file

@ -7,18 +7,23 @@ defined('TYPO3') || die();
// extension name, matching the PHP namespaces (but without the vendor)
'Tea',
// arbitrary, but unique plugin name (not visible in the BE)
'Tea',
'TeaIndex',
// plugin title, as visible in the drop-down in the BE
'LLL:EXT:tea/Resources/Private/Language/locallang.xlf:plugin.tea',
'LLL:EXT:tea/Resources/Private/Language/locallang.xlf:plugin.tea_index',
// the icon visible in the drop-down in the BE
'EXT:tea/Resources/Public/Icons/Extension.svg'
);
// This removes the default controls from the plugin.
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['tea_tea'] = 'recursive,select_key,pages';
// These two commands add the flexform configuration for the plugin.
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['tea_tea'] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue(
'tea_tea',
'FILE:EXT:tea/Configuration/FlexForms/Plugin.xml'
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'Tea',
'TeaShow',
'LLL:EXT:tea/Resources/Private/Language/locallang.xlf:plugin.tea_show',
'EXT:tea/Resources/Public/Icons/Extension.svg'
);
// This removes the default controls from the plugin.
$controlsToRemove = 'recursive,select_key,pages';
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist'] = [
'tea_teaindex' => $controlsToRemove,
'tea_teashow' => $controlsToRemove,
];

View file

@ -3,19 +3,11 @@
<file source-language="en" target-language="de" datatype="plaintext" original="messages">
<header/>
<body>
<trans-unit id="plugin.tea">
<source>Tea</source>
<target>Tee</target>
</trans-unit>
<trans-unit id="plugin.tea.view">
<source>View</source>
<target>Ansicht</target>
</trans-unit>
<trans-unit id="plugin.tea.index">
<trans-unit id="plugin.tea_index">
<source>Tea list</source>
<target>Teeliste</target>
</trans-unit>
<trans-unit id="plugin.tea.show">
<trans-unit id="plugin.tea_show">
<source>Tea single view</source>
<target>Tee-Einzelansicht</target>
</trans-unit>

View file

@ -3,16 +3,10 @@
<file source-language="en" datatype="plaintext" original="messages">
<header/>
<body>
<trans-unit id="plugin.tea">
<source>Tea</source>
</trans-unit>
<trans-unit id="plugin.tea.view">
<source>View</source>
</trans-unit>
<trans-unit id="plugin.tea.index">
<trans-unit id="plugin.tea_index">
<source>Tea list</source>
</trans-unit>
<trans-unit id="plugin.tea.show">
<trans-unit id="plugin.tea_show">
<source>Tea single view</source>
</trans-unit>
<trans-unit id="index.heading">

View file

@ -25,7 +25,7 @@
{tea.uid}
</td>
<td>
<f:link.action arguments="{tea: tea}" pageUid="{settings.singleViewPageUid}">
<f:link.action action="show" arguments="{tea: tea}" pageUid="{settings.singleViewPageUid}">
{tea.title}
</f:link.action>
</td>

View file

@ -8,14 +8,24 @@ defined('TYPO3') or die('Access denied.');
// extension name, matching the PHP namespaces (but without the vendor)
'Tea',
// arbitrary, but unique plugin name (not visible in the BE)
'Tea',
'TeaIndex',
// all actions
[
\TTN\Tea\Controller\TeaController::class => 'index, show',
\TTN\Tea\Controller\TeaController::class => 'index',
],
// non-cacheable actions
[
\TTN\Tea\Controller\TeaController::class => '',
]
);
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Tea',
'TeaShow',
[
\TTN\Tea\Controller\TeaController::class => 'show',
],
[
\TTN\Tea\Controller\TeaController::class => '',
]
);
})();