[TASK] Enable site config utility to handle references

This commit is contained in:
Philipp Dieter
2022-04-27 13:28:02 +02:00
parent c72f1fd4de
commit 138c9373ff
2 changed files with 24 additions and 3 deletions

View File

@@ -15,6 +15,7 @@ namespace Cjel\TemplatesAide\Utility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser;
/**
* Utility to work with site config
@@ -35,20 +36,33 @@ class SiteConfigUtility
$objectManager = GeneralUtility::makeInstance(
ObjectManager::class
);
$typoScriptParser = GeneralUtility::makeInstance(
TypoScriptParser::class
);
$configurationManager = $objectManager->get(
ConfigurationManagerInterface::class
);
$typoscript = $configurationManager->getConfiguration(
ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT
);
$typoscript = GeneralUtility::removeDotsFromTS($typoscript);
$siteConfig = $typoscript;
if ($limitToSiteConfig) {
$siteConfig = $typoscript['config']['site'];
$siteConfig = $typoscript['config.']['site.'];
}
$current = &$siteConfig;
foreach ($pathParts as $key) {
if ($current[$key . '.']) {
$key .= '.';
}
$current = &$current[$key];
if (isset($current[0]) && $current[0] === '<') {
$searchkey = trim(substr($current, 1));
list($name, $conf) = $typoScriptParser->getVal(
$searchkey,
$typoscript
);
$current = $conf;
}
}
if (is_array($current)
&& array_key_exists('value', $current)