diff --git a/public/typo3conf/ext/ep_products/Classes/Service/MyEpUrlResolverService.php b/public/typo3conf/ext/ep_products/Classes/Service/MyEpUrlResolverService.php index b6868cbb..5b4dc305 100644 --- a/public/typo3conf/ext/ep_products/Classes/Service/MyEpUrlResolverService.php +++ b/public/typo3conf/ext/ep_products/Classes/Service/MyEpUrlResolverService.php @@ -5,35 +5,51 @@ namespace EP\EpProducts\Service; use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Configuration\ConfigurationManager; +use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; class MyEpUrlResolverService implements SingletonInterface { - /** @var string */ - private $productionUrl; - - /** @var string */ - private $stagingUrl; - - public function __construct() - { - $config = GeneralUtility::makeInstance(ExtensionConfiguration::class); - $this->productionUrl = (string) $config->get('ep_products', 'myEpUrl'); - $this->stagingUrl = (string) $config->get('ep_products', 'myEpStagingUrl'); - } - /** * Returns the staging URL when the `ep_myep_staging` cookie is set and a staging URL * is configured. Falls back to the production URL in all other cases. - * - * Both URLs are read from the extension configuration (Extension Manager), - * bypassing TypoScript to avoid constant-override collisions. */ public function resolve(): string { - if ('' !== $this->stagingUrl && !empty($_COOKIE['ep_myep_staging'])) { - return $this->stagingUrl; + $config = GeneralUtility::makeInstance(ExtensionConfiguration::class); + $settings = $this->getTypoScriptSettings(); + $productionUrl = $this->resolveUrlSetting( + $settings, + 'myEpUrl', + (string) $config->get('ep_products', 'myEpUrl') + ); + $stagingUrl = $this->resolveUrlSetting( + $settings, + 'myEpStagingUrl', + (string) $config->get('ep_products', 'myEpStagingUrl') + ); + + if ('' !== $stagingUrl && !empty($_COOKIE['ep_myep_staging'])) { + return $stagingUrl; } - return $this->productionUrl; + return $productionUrl; + } + + private function getTypoScriptSettings(): array + { + $configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class); + $settings = GeneralUtility::removeDotsFromTS( + $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT) + ); + + return $settings['plugin']['tx_epproducts']['settings'] ?? []; + } + + private function resolveUrlSetting(array $settings, string $key, string $fallback): string + { + $value = trim((string) ($settings[$key] ?? '')); + + return $value !== '' ? $value : $fallback; } } diff --git a/public/typo3conf/ext/ep_products/Configuration/TypoScript/constants.typoscript b/public/typo3conf/ext/ep_products/Configuration/TypoScript/constants.typoscript index ec2ab3dc..f263f449 100644 --- a/public/typo3conf/ext/ep_products/Configuration/TypoScript/constants.typoscript +++ b/public/typo3conf/ext/ep_products/Configuration/TypoScript/constants.typoscript @@ -54,6 +54,10 @@ plugin.tx_epproducts { searchLogIgnoreIps = # cat=epproducts/140/120; type=string; label=Concept UIDs to trigger inquiry form on product detail page (CSV) groupInquiryFormConceptUids = + # cat=epproducts/140/130; type=string; label=Per-site MyE&P booking URL override + myEpUrl = + # cat=epproducts/140/140; type=string; label=Per-site MyE&P staging booking URL override + myEpStagingUrl = } persistence { # cat=epproducts/100/100; type=string; label=Default storage PID diff --git a/public/typo3conf/ext/ep_products/Configuration/TypoScript/setup.typoscript b/public/typo3conf/ext/ep_products/Configuration/TypoScript/setup.typoscript index a494397c..7eecbe49 100644 --- a/public/typo3conf/ext/ep_products/Configuration/TypoScript/setup.typoscript +++ b/public/typo3conf/ext/ep_products/Configuration/TypoScript/setup.typoscript @@ -38,6 +38,8 @@ plugin.tx_epproducts { noInfoConceptUids = {$plugin.tx_epproducts.settings.noInfoConceptUids} priceTableRoomTypes = {$plugin.tx_epproducts.settings.priceTableRoomTypes} searchLogIgnoreIps = {$plugin.tx_epproducts.settings.searchLogIgnoreIps} + myEpUrl = {$plugin.tx_epproducts.settings.myEpUrl} + myEpStagingUrl = {$plugin.tx_epproducts.settings.myEpStagingUrl} groupsPageUid = {$plugin.tx_eptheme.settings.groupsPageUid} travelInfoPageUid = {$plugin.tx_eptheme.settings.travelInfoPageUid} groupsContactFormPageUid = {$plugin.tx_eptheme.settings.groupsContactFormPageUid}