Created
October 8, 2024 08:05
-
-
Save sorenmalling/b823897b1c3e1e95d0e849aeabbaf4f6 to your computer and use it in GitHub Desktop.
tsfe.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function tsfe(ServerRequestInterface $request): TypoScriptFrontendController | |
{ | |
/** @var Site $site */ | |
$site = $request->getAttribute('site'); | |
$language = $request->getAttribute('language') ?? $site->getDefaultLanguage(); | |
$context = clone GeneralUtility::makeInstance(Context::class); | |
$languageAspect = LanguageAspectFactory::createFromSiteLanguage($language); | |
$context->setAspect('language', $languageAspect); | |
$context->setAspect( | |
'visibility', | |
GeneralUtility::makeInstance( | |
VisibilityAspect::class, | |
false, | |
false | |
) | |
); | |
$feUser = GeneralUtility::makeInstance(FrontendUserAuthentication::class); | |
$feUser->user = ['uid' => 0, 'username' => '', 'usergroup' => '' ]; | |
$feUser->fetchGroupData($request); | |
$pageArguments = GeneralUtility::makeInstance(PageArguments::class, $site->getRootPageId(), '0', []); | |
/** @var TypoScriptFrontendController $tsfe */ | |
$tsfe = GeneralUtility::makeInstance(TypoScriptFrontendController::class, $context, $site, $language, $pageArguments, $feUser); | |
$template = GeneralUtility::makeInstance(TemplateService::class, $context, null, $tsfe); | |
$template->tt_track = false; | |
$tsfe->tmpl = $template; | |
$context->setAspect('typoscript', GeneralUtility::makeInstance(TypoScriptAspect::class, true)); | |
$tsfe->newCObj($request); | |
return $tsfe; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment