Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make component settings work in TYPO3 v13 #174

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions Classes/Utility/ComponentSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

use ArrayAccess;
use ReturnTypeWillChange;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\TypoScript\TypoScriptService;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class ComponentSettings implements \TYPO3\CMS\Core\SingletonInterface, ArrayAccess
{
Expand All @@ -23,11 +25,23 @@ public function __construct(protected TypoScriptService $typoScriptService)
*/
public function reset(): void
{
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 13) {
$typoScriptSettings = $GLOBALS['TSFE']->tmpl->setup['config.']['tx_fluidcomponents.']['settings.'] ?? [];
} else {
// This is only a temporary workaround to get the TypoScript settings from the current request.
// Using the global $GLOBALS['TSFE'] is not the correct way to get the TypoScript settings but for now
// the only without a major refactoring and breaking changes.
// ComponentSettings should not be singeltons.
// ComponentSettings should be refactored to use a factory pattern using a request object to build the
// settings with the correct typoscript from the current request.
// The "reset()" method should be removed then as a "clean" component settings object should always be
// created by the factory.
$request = $GLOBALS['TYPO3_REQUEST'] ?? null;
$typoScriptSettings = $request?->getAttribute('frontend.typoscript')->getSetupArray()['config.']['tx_fluidcomponents.']['settings.'] ?? [];
}
$this->settings = array_merge(
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['fluid_components']['settings'] ?? [],
$this->typoScriptService->convertTypoScriptArrayToPlainArray(
$GLOBALS['TSFE']->tmpl->setup['config.']['tx_fluidcomponents.']['settings.'] ?? []
)
$this->typoScriptService->convertTypoScriptArrayToPlainArray($typoScriptSettings)
);
}

Expand Down