Reputation: 33
In my TYPO3 extension, I made a custom controller class that is called from some hook in the TYPO3 backend.
In this controller I would like to get some stuff from $GLOBALS['TSFE']
but when I do var_dump($GLOBALS['TSFE'])
I receive null
. The question is how can I correctly initialize $GLOBALS['TSFE'
]?
Upvotes: 3
Views: 3689
Reputation:
While $GLOBALS['TSFE'] is the instantiation of TypoScriptFrontendController and you can correctly instantiate it with makeInstance as described, why would you want to do that?
As you said, you are working in the Backend, TypoScriptFrontendController gives you various information about the currently rendered page (in the Frontend).
So, while you can instantiate the TSTypoScriptFrontendControllerFE, there is usually no need to: TYPO3 instantiates it in the Frontend.
Before instantiating it, I would first check: What's the usecase? And maybe there is some better way to do what you want to do.
Upvotes: 2
Reputation: 1623
try something like this:
$GLOBALS['TSFE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController',$GLOBALS['TYPO3_CONF_VARS'], $id, $type);
Upvotes: 4