extbasetypo3-9.x

How to rework addAdditionalHeaderData within TYPO3 9.5


While upgrading our codebase for 9.5 I just found the old approach with using

$res = $this->response;
$res->addAdditionalHeaderData('<script src="' . $scriptPath . '" type="text/javascript"></script>');

This all happens inside an extension controller extending ActionController, the methods seem not to exist anymore and I can't find a new way of implementing that functionality.

So how can I add additional header data inside my action controller from my extbase extension?

Help is much appreciated.


Solution

  • we did it with the PageRenderer class which can be instantiated within the ActionController

        /** @var PageRenderer $pageRenderer */
        $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
        $pageRenderer->addHeaderData($additionalHeaderData);