Skip to content

Commit

Permalink
[TASK] Avoid deprecated EMU::addPageTSConfig() (#1518)
Browse files Browse the repository at this point in the history
Register own condition matcher to access ExtensionConfiguration
toggles. Switch from INCLUDE_TYPOSCRIPT to @import.
  • Loading branch information
lolli42 authored Oct 11, 2024
1 parent f65c7be commit ca6bd80
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ indent_size = 3
max_line_length = 80

# TypoScript
[*.typoscript]
[{*.typoscript,*.tsconfig}]
indent_style = space
indent_size = 4

Expand Down
1 change: 1 addition & 0 deletions Classes/ExpressionLanguage/ConditionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function __construct()
{
$this->expressionLanguageVariables = [
'extension' => GeneralUtility::makeInstance(ExtensionWrapper::class),
'extensionConfiguration' => GeneralUtility::makeInstance(ExtensionConfigurationWrapper::class),
];
}
}
31 changes: 31 additions & 0 deletions Classes/ExpressionLanguage/ExtensionConfigurationWrapper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
declare(strict_types = 1);

/*
* This file is part of the package bk2k/bootstrap-package.
*
* For the full copyright and license information, please read the
* LICENSE file that was distributed with this source code.
*/

namespace BK2K\BootstrapPackage\ExpressionLanguage;

use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;

#[Autoconfigure(public: true)]
final class ExtensionConfigurationWrapper
{
public function __construct(
private readonly ExtensionConfiguration $extensionConfiguration,
) {
}

/**
* True if a bool toggle in ext_conf_template is true'ish.
*/
public function isToggleEnabled(string $extensionKey, string $extConfTemplateToggle): bool
{
return (bool)$this->extensionConfiguration->get($extensionKey, $extConfTemplateToggle);
}
}
29 changes: 29 additions & 0 deletions Configuration/page.tsconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[!extensionConfiguration.isToggleEnabled('bootstrap_package', 'disablePageTsContentElements')]
# Add Content Elements
@import 'EXT:bootstrap_package/Configuration/TsConfig/Page/ContentElement/All.tsconfig'
[end]

[!extensionConfiguration.isToggleEnabled('bootstrap_package', 'disablePageTsBackendLayouts')]
# Add BackendLayouts for the BackendLayout DataProvider
@import 'EXT:bootstrap_package/Configuration/TsConfig/Page/Mod/WebLayout/BackendLayouts.tsconfig'
[end]

[!extensionConfiguration.isToggleEnabled('bootstrap_package', 'disablePageTsRTE')]
# RTE
@import 'EXT:bootstrap_package/Configuration/TsConfig/Page/RTE.tsconfig'
[end]

[!extensionConfiguration.isToggleEnabled('bootstrap_package', 'disablePageTsTCADefaults')]
# TCADefaults
@import 'EXT:bootstrap_package/Configuration/TsConfig/Page/TCADefaults.tsconfig'
[end]

[!extensionConfiguration.isToggleEnabled('bootstrap_package', 'disablePageTsTCEMAIN')]
# TCEMAIN
@import 'EXT:bootstrap_package/Configuration/TsConfig/Page/TCEMAIN.tsconfig'
[end]

[!extensionConfiguration.isToggleEnabled('bootstrap_package', 'disablePageTsTCEFORM')]
# TCEFORM
@import 'EXT:bootstrap_package/Configuration/TsConfig/Page/TCEFORM.tsconfig'
[end]
32 changes: 0 additions & 32 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,6 @@
\TYPO3\CMS\Core\Configuration\ExtensionConfiguration::class
);

// PageTS

// Add Content Elements
if (!(bool) $extensionConfiguration->get('bootstrap_package', 'disablePageTsContentElements')) {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:bootstrap_package/Configuration/TsConfig/Page/ContentElement/All.tsconfig">');
}

// Add BackendLayouts for the BackendLayout DataProvider
if (!(bool) $extensionConfiguration->get('bootstrap_package', 'disablePageTsBackendLayouts')) {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:bootstrap_package/Configuration/TsConfig/Page/Mod/WebLayout/BackendLayouts.tsconfig">');
}

// RTE
if (!(bool) $extensionConfiguration->get('bootstrap_package', 'disablePageTsRTE')) {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:bootstrap_package/Configuration/TsConfig/Page/RTE.tsconfig">');
}

// TCADefaults
if (!(bool) $extensionConfiguration->get('bootstrap_package', 'disablePageTsTCADefaults')) {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:bootstrap_package/Configuration/TsConfig/Page/TCADefaults.tsconfig">');
}

// TCEMAIN
if (!(bool) $extensionConfiguration->get('bootstrap_package', 'disablePageTsTCEMAIN')) {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:bootstrap_package/Configuration/TsConfig/Page/TCEMAIN.tsconfig">');
}

// TCEFORM
if (!(bool) $extensionConfiguration->get('bootstrap_package', 'disablePageTsTCEFORM')) {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:bootstrap_package/Configuration/TsConfig/Page/TCEFORM.tsconfig">');
}

// Register custom EXT:form configuration
if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('form')) {
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptSetup(trim('
Expand Down

0 comments on commit ca6bd80

Please sign in to comment.