A very similar question has already been asked here. I tried to comment to emphasize, but I am not allowed. I tried asking my question in an answer there, but it was deleted instantly. Understandable, but not helpful.
In TYPO3 12, there are possibilities to get TypoScript in the backend using TYPO3\CMS\Core\TypoScript\TemplateService
or TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager
.
In TYPO3 13, BackendConfigurationManager
is declared as final, so one can't set the page id (see question noted above). The use of TemplateService
is deprecated. There seems to be an idea of not using TypoScript in the backend, which is technically perfectly logical, but it needs a replacement in real life. There are probably a lot of use cases. Here's mine:
Cut short: I also need access to TypoScript from the Backend Class, outside of the Extbase Controller. Working for TYPO3 12 using TYPO3\CMS\Core\TypoScript\TemplateService or BackendConfigurationManager as mentioned above. No working version for TYPO3 13.
Thanks for any hint on best practice!
There is no need to extend the BackendConfigurationManager and having it final is therefor more than okay (beside it's a internal implementation anyway).
The "page id" can be set as part of the request which needs to be passed:
$request = (new ServerRequest())->withQueryParams(['id' => 1]);
$backendConfigurationManager = GeneralUtility::makeInstance(
BackendConfigurationManager::class
);
$typoScript = $backendConfigurationManager->getTypoScriptSetup($request);
For v12 that would be more like:
$request = (new ServerRequest())->withQueryParams(['id' => 1]);
$backendConfigurationManager = GeneralUtility::makeInstance(
BackendConfigurationManager::class
);
$backendConfigurationManager->setRequest($request);
$typoScript = $backendConfigurationManager->getTypoScriptSetup();
The (Frontend/Backend)ConfigurationManager instances were never desigened for direct usage and should in general handled over the ConfigurationManagerInterface
which retrives the correct once based on the request set (which requires to set more to the request).
Note that it may be required to enrich the request further but should be at least the basic kickoff to the route.
There seems to be an idea of not using TypoScript in Backend ...
TypoScript is the Frontend Rendering Configuration and was it always. Using it in the backend is technical dept and wrong in anyway, already from the beginning.
TypoScript parsing comes with a cost and has been reduced in the backend due to performance concerns, for example by moving backend fluid view configuration from TypoScript to PageTSConfig (see module templating api changes of v12).
However, using SiteConfiguration and SiteSettings (with v13 as sitesets) you would have the configuration availbe in frontend TypoScript as TypoScript constants and it ca be simply retrieved by getting the site configuration using the SiteFinder
instead of the extbase BackendConfigurationManager ... and would also cut the "dependency" to extbase.