Skip to content
Snippets Groups Projects
Commit ec9cc899 authored by Matthias Adrowski's avatar Matthias Adrowski
Browse files

[TASK] Migrate BackendController

parent 24aeb34b
No related branches found
No related tags found
1 merge request!38Feature upgrade to typo3 11
......@@ -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()));
}
}
......@@ -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());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment