[TASK] Add function to get site config by typoscript path

This commit is contained in:
Philipp Dieter 2021-05-02 13:17:04 +02:00
parent c4f9c16ff7
commit b6b02e0394

View File

@ -0,0 +1,50 @@
<?php
namespace Cjel\TemplatesAide\Utility;
/***
*
* This file is part of the "" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2021 Philipp Dieter
*
***/
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Object\ObjectManager;
/**
* Utility to work with site config
*/
class SiteConfigUtility
{
/**
* Gets site config by typoscript path
*
* @var string $path
* @return string
*/
public static function getByPath($path)
{
$pathParts = explode('.', $path);
$objectManager = GeneralUtility::makeInstance(
ObjectManager::class
);
$configurationManager = $objectManager->get(
ConfigurationManagerInterface::class
);
$typoscript = $configurationManager->getConfiguration(
ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT
);
$typoscript = GeneralUtility::removeDotsFromTS($typoscript);
$siteConfig = $typoscript['config']['site'];
$current = &$siteConfig;
foreach ($pathParts as $key) {
$current = &$current[$key];
}
return $current;
}
}