2

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:

  • Backend Class to extend Link Handler with a possibility to link to a specific record (detail page).
  • The record is no extbase-record, though, but fetched from external. So, technically speaking, I need just a link to a specific detail page, adding one or multiple parameters. Only that the uid of this detail page can not be hard-coded.
  • The package is technically demanding and reusable. The mentioned detail page for a specific Installation is now defined by editors using TypoScript constants. The setting is used on multiple occasions (FE plugins) - not only for the link handler. There are other settings also.
  • I do not see a reasonable possibility for the editor to set the same setting by TSConfig (apart from the fact that this kind of redundancy would be unclean and error-prone). Basically, this constant should be enough for all use cases, so also for the link handler. For TYPO3 12 it works just that way.
  • Although I think it's good to have all the settings in one place for ease of use, I'm generally open to another solution if necessary. I need advice and expertise, though. It seems a problem touched by future strategy, maybe.

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!

1

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.