[BUGFIX] Deal with non-public internal TYPO3 services
TYPO3 v13 requires some services to create frontend
environment which are not made public by the core,
mainly because they are injected and due to the
@internal flag no need to do it so.
To understand the strategy used in this change it's important to know in which steps the DI container is created in TYPO3, which is literally following:
-
ServiceProviderfor lowlevel/failsafe container to make services available also inEXT:installcontext. This is not documented and communicated, considered mainly for TYPO3 internal usage. This provides factories and extension available in failsafe and not failsave container context and everything below only for non-failsafe context. -
Iterate over
Configuration/Services.yamlfiles from TYPO3 extensions, and based on the provided resources first respect and configurate definitions based on php attributes and manually based on entries in the file. -
Iterate over
Configuration/Services.phpfiles from TYPO3 extensions, and based on eventually included resource path load definitions scan PHP attributes again to estend/replace service definitions and directly added definitions. As this is executed code conditional registrations can be done using PHP functionalites, for example usingclass_exist()checks.
This change uses following strategies to prepare the frontend simulation for dependency injection while keeping it compatible with multiple TYPO3 versions:
-
Adding
#[Exclude]to the TYPO3 version depending implementation to keep them included. -
Introdcing the
Configuration/Services.phpfile to make version based conditional service configuration possible:-
Allow
autoconfigurationandautowiringonly for the Frontend Simulation class suitable for the current installed TYPO3 version and make it public retrieveable from the DI container, for example usingGeneralUtility::makeInstance(). -
Set an alias for the
FrontendSimulationInterfaceto the version related implementation service and make it public instanciable, which allows to use the interface forconstructororinject-methoddependency injection in the future and allow to retrieve it using$frontendSimulation = GeneralUtility::makeInstance( FrontendSimulationInterface::class ); -
Reconfigure the definition for TYPO3 v13 services only on v13 using
class_exist()checks to make them public retrieveable. -
FrontendSimulationv13no longer extends theFrontendSimulationv12class and implements the interface now, which required that methodcleanupTSFE()has been cloned and unsetting the TYPO3 v12 typoscript context aspect removed. -
FrontendSimulationv12::cleanupTSFE()has been modified and the TYPO3 v13frontend.previewcontext is no longer unset. -
AuthenticationService::getFrontendSimulation()has been streamlined to use theFrontendSimulationInterfaceto retrieve the suitable implementation for current TYPO3 versions allowing to remove TYPO3 Version related code here and some use import statements.
-
Resolves: #231
Thanks for your work. Since I failed to reproduce the bug, I still wait for better feedback on how to reproduce the issue.