Settings::getConstants()
\nn\t3::Settings()->getConstants($tsPath = '');
Get array of TypoScript constants.
\nn\t3::Settings()->getConstants();
\nn\t3::Settings()->getConstants('path.to.constant');
Copied!
Also exists as ViewHelper:
{nnt3:ts.constants(path:'path.to.constant')}
Copied!
| @return array
Source Code
public function getConstants ( $tsPath = '' )
{
$constants = [];
if ($request = $GLOBALS['TYPO3_REQUEST'] ?? false) {
if ($ts = $request->getAttribute('frontend.typoscript')) {
try {
$constants = $ts->getSettingsTree()->toArray();
} catch ( \Exception $e ) {
// this might be related to https://forge.typo3.org/projects/typo3cms-core/issues
\nn\t3::Exception('TypoScript-Setup could not be loaded. If you are trying to access it from a Middleware or the CLI, try using $request->getAttribute(\'frontend.controller\')->config[\'INTincScript\'][] = []; in your Middleware to disable caching.');
}
}
}
$config = \nn\t3::TypoScript()->convertToPlainArray( $constants );
return $tsPath ? $this->getFromPath( $tsPath, $config ) : $config;
}
Copied!