diff --git a/Classes/Controller/AbstractController.php b/Classes/Controller/AbstractController.php index 1c710e0e2bc6a2f36737ab58669751ddac1875e5..52b94144f1118471a5dcc645b89be87ad8b6be93 100644 --- a/Classes/Controller/AbstractController.php +++ b/Classes/Controller/AbstractController.php @@ -215,4 +215,17 @@ abstract class AbstractController extends ActionController { } return $offset; } + + /** + * Build Typo3 11 Response + * @param string|NULL $html + * @return \Psr\Http\Message\ResponseInterface + */ + protected function htmlResponse(string $html = null): \Psr\Http\Message\ResponseInterface + { + return $this->responseFactory->createResponse() + ->withHeader('Content-Type', 'text/html; charset=utf-8') + ->withBody($this->streamFactory->createStream($html ?? $this->view->render())); + } + } diff --git a/Classes/Controller/BackendController.php b/Classes/Controller/BackendController.php index 3db08d161509b3d0b0b21df28311baa094ad2bb1..eb027af0f4e1c781abf0f9c1268dde792043e530 100644 --- a/Classes/Controller/BackendController.php +++ b/Classes/Controller/BackendController.php @@ -131,12 +131,11 @@ class BackendController extends ActionController { } /** - * @param array $filters - * @throws \InvalidArgumentException - * @throws \UnexpectedValueException + * @param array|null $filters + * @return \Psr\Http\Message\ResponseInterface|null * @throws \TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException */ - public function indexAction(array $filters = NULL) { + public function indexAction(array $filters = NULL): ?\Psr\Http\Message\ResponseInterface { $showNewsList = FALSE; if ( ($this->pageUid && $this->pageUid === $this->rootPageUid) || @@ -168,6 +167,13 @@ class BackendController extends ActionController { $this->view->assign('alternativePageOptions', $alternativePageOptions); } $this->view->assign('showNewsList', $showNewsList); + + if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '11.0.0', '<')) { + return NULL; + } + else { + return $this->createBackendResponse(); + } } /** @@ -236,4 +242,17 @@ class BackendController extends ActionController { } $this->docHeaderComponent->getMenuRegistry()->addMenu($languageMenu); } + + + /** + * Use the ModuleTemplateResponse to create a response object for the backend + * + * @return \Psr\Http\Message\ResponseInterface + */ + protected function createBackendResponse(): \Psr\Http\Message\ResponseInterface + { + $moduleTemplate = $this->moduleTemplateFactory->create($this->request); + $moduleTemplate->setContent($this->view->render()); + return $this->htmlResponse($moduleTemplate->renderContent()); + } }