Skip to content

Commit 2fb5982

Browse files
WebsiteDeveloperdkd-kaehm
authored andcommitted
[BUGFIX] pass a request with page id to Configuration manager
This fixes an issue where, in a multi page TYPO3 installation, if both pages have different setups for available templates the previous code would always use the first pages config Fixes: #4451 Ports: #4452
1 parent 8dab2e1 commit 2fb5982

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Classes/System/UserFunctions/FlexFormUserFunctions.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@
2323
use ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration;
2424
use ApacheSolrForTypo3\Solr\System\Solr\SolrConnection;
2525
use Doctrine\DBAL\Exception as DBALException;
26+
use TYPO3\CMS\Core\Http\ServerRequest;
2627
use TYPO3\CMS\Core\Utility\GeneralUtility;
28+
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
2729
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
30+
use TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException;
2831
use TYPO3\CMS\Extbase\Utility\LocalizationUtility;
2932

3033
use function str_starts_with;
@@ -39,6 +42,7 @@ class FlexFormUserFunctions
3942
*
4043
* @throws NoSolrConnectionFoundException
4144
* @throws DBALException
45+
* @throws InvalidConfigurationTypeException
4246
*/
4347
public function getFacetFieldsFromSchema(array &$parentInformation): void
4448
{
@@ -99,6 +103,8 @@ protected function getParsedSolrFieldsFromSchema(array $configuredFacets, array
99103

100104
/**
101105
* Retrieves the configured facets for a page.
106+
*
107+
* @throws InvalidConfigurationTypeException
102108
*/
103109
protected function getConfiguredFacetsForPage(?int $pid = null): ?array
104110
{
@@ -141,6 +147,8 @@ protected function getFieldNamesFromSolrMetaDataForPage(array $pageRecord): arra
141147

142148
/**
143149
* Enriches the parents information with information from template
150+
*
151+
* @throws InvalidConfigurationTypeException
144152
*/
145153
public function getAvailableTemplates(array &$parentInformation): void
146154
{
@@ -191,21 +199,30 @@ protected function getTypoScriptTemplateKeyFromFieldName(array $parentInformatio
191199

192200
/**
193201
* Returns TypoScriptConfiguration if is available or can be resolved for given pid
202+
*
203+
* @throws InvalidConfigurationTypeException
194204
*/
195205
protected function getConfigurationFromPageId(?int $pid = null): ?TypoScriptConfiguration
196206
{
197207
if ($pid === null) {
198208
return null;
199209
}
200210

211+
/** @var ConfigurationManager $configurationManager */
201212
$configurationManager = GeneralUtility::makeInstance(ConfigurationManagerInterface::class);
213+
214+
$request = (new ServerRequest())->withQueryParams(['id' => $pid]);
215+
/** @noinspection PhpInternalEntityUsedInspection */
216+
$configurationManager->setRequest($request);
202217
$typoScript = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
203218

204219
return GeneralUtility::makeInstance(TypoScriptConfiguration::class, $typoScript);
205220
}
206221

207222
/**
208223
* Retrieves the configured templates from TypoScript.
224+
*
225+
* @throws InvalidConfigurationTypeException
209226
*/
210227
protected function getAvailableTemplateFromTypoScriptConfiguration(int $pageId, string $templateKey): array
211228
{

0 commit comments

Comments
 (0)