Commit e487cf52 authored by Christian Kuhn's avatar Christian Kuhn
Browse files

[TASK] Create own response instance in controller actions

To further support the PSR-7 / PSR-15 and removal of
GeneralUtility::_GP() and friends efforts, all controllers
no longer use the second 'ResponseInterface $response'
argument given by dispatchers: Dispatchers should not
assume which type of response a controller returns, there
is no point in preparing this object.

Instead, controllers now always create one of
HtmlResponse, JsonResponse or RedirectResponse on
their own and return these objects.

Changes overview:
* Always use "new" to instantiate a response, PSR-15
  middlewares allow fiddling with the object if needed,
  xclassing these classes is never needed, we instead
  can rely on proper API usage.
* All controller actions drop the second $response argument
  and add ResponseInterface return type hint.
* Some controllers action also drop first $request argument,
  but only if the action does not need access to ServerParams
  at all. Those controllers that access _GP or _POST or similar
  currently, keep $request for now - they have to be refactored
  later anyway and then need $request.

Change-Id: Icce283b3c19be14ef1adeec761cfd63c90ab24c5
Resolves: #83939
Releases: master
Reviewed-on: https://review.typo3.org/55754

Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: default avatarMathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: default avatarMathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Benjamin Kott's avatarBenjamin Kott <benjamin.kott@outlook.com>
Tested-by: Benjamin Kott's avatarBenjamin Kott <benjamin.kott@outlook.com>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 2b6a19ea
......@@ -15,7 +15,6 @@ namespace TYPO3\CMS\About\Controller;
*/
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Module\ModuleLoader;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
......@@ -46,10 +45,9 @@ class AboutController
/**
* Main action: Show standard information
*
* @param ServerRequestInterface $request the incoming PSR-7 request
* @return ResponseInterface the HTML output
*/
public function indexAction(ServerRequestInterface $request): ResponseInterface
public function indexAction(): ResponseInterface
{
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
$this->initializeView('index');
......
......@@ -23,6 +23,7 @@ use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryHelper;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Http\JsonResponse;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
......@@ -142,8 +143,6 @@ class ShortcutToolbarItem implements ToolbarItemInterface
* Render drop down content
*
* @return string HTML
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidExtensionNameException
* @throws \InvalidArgumentException
*/
public function getDropDown()
{
......@@ -166,17 +165,11 @@ class ShortcutToolbarItem implements ToolbarItemInterface
/**
* Renders the menu so that it can be returned as response to an AJAX call
*
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @return ResponseInterface
*/
public function menuAction(ServerRequestInterface $request, ResponseInterface $response)
public function menuAction(): ResponseInterface
{
$menuContent = $this->getDropDown();
$response->getBody()->write($menuContent);
$response = $response->withHeader('Content-Type', 'text/html; charset=utf-8');
return $response;
return new HtmlResponse($this->getDropDown());
}
/**
......@@ -442,16 +435,12 @@ class ShortcutToolbarItem implements ToolbarItemInterface
}
/**
* Fetches the available shortcut groups, renders a form so it can be saved later on, usually called via AJAX
* Fetches the available shortcut groups, renders a form so it can be saved later on, called via AJAX
*
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @return ResponseInterface the full HTML for the form
* @throws \TYPO3\CMS\Extbase\Mvc\Exception\InvalidExtensionNameException
* @throws \RuntimeException
* @throws \InvalidArgumentException
*/
public function editFormAction(ServerRequestInterface $request, ResponseInterface $response)
public function editFormAction(ServerRequestInterface $request): ResponseInterface
{
$parsedBody = $request->getParsedBody();
$queryParams = $request->getQueryParams();
......@@ -474,8 +463,7 @@ class ShortcutToolbarItem implements ToolbarItemInterface
$editFormView->assign('selectedShortcut', $selectedShortcut);
$editFormView->assign('shortcutGroups', $shortcutGroups);
$response->getBody()->write($editFormView->render());
return $response->withHeader('Content-Type', 'text/html; charset=utf-8');
return new HtmlResponse($editFormView->render());
}
/**
......@@ -507,17 +495,17 @@ class ShortcutToolbarItem implements ToolbarItemInterface
$success = true;
}
}
return GeneralUtility::makeInstance(JsonResponse::class, ['success' => $success]);
return new JsonResponse(['success' => $success]);
}
/**
* Creates a shortcut through an AJAX call
*
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @return ResponseInterface
* @throws \RuntimeException
*/
public function createShortcutAction(ServerRequestInterface $request, ResponseInterface $response)
public function createShortcutAction(ServerRequestInterface $request): ResponseInterface
{
$languageService = $this->getLanguageService();
$parsedBody = $request->getParsedBody();
......@@ -539,76 +527,76 @@ class ShortcutToolbarItem implements ToolbarItemInterface
$queryParameters = GeneralUtility::explodeUrl2Array($queryParts['query'], true);
// Proceed only if no scheme is defined, as URL is expected to be relative
if (empty($queryParts['scheme'])) {
if (is_array($queryParameters['edit'])) {
$shortcut['table'] = key($queryParameters['edit']);
$shortcut['recordid'] = key($queryParameters['edit'][$shortcut['table']]);
$shortcut['pid'] = BackendUtility::getRecord($shortcut['table'], $shortcut['recordid'])['pid'];
if ($queryParameters['edit'][$shortcut['table']][$shortcut['recordid']] === 'edit') {
$shortcut['type'] = 'edit';
$shortcutNamePrepend = htmlspecialchars($languageService->getLL('shortcut_edit'));
} elseif ($queryParameters['edit'][$shortcut['table']][$shortcut['recordid']] === 'new') {
$shortcut['type'] = 'new';
$shortcutNamePrepend = htmlspecialchars($languageService->getLL('shortcut_create'));
}
} else {
$shortcut['type'] = 'other';
$shortcut['table'] = '';
$shortcut['recordid'] = 0;
if (!empty($queryParameters['scheme'])) {
throw new \RuntimeException('relative url expected', 1518785877);
}
if (is_array($queryParameters['edit'])) {
$shortcut['table'] = key($queryParameters['edit']);
$shortcut['recordid'] = key($queryParameters['edit'][$shortcut['table']]);
$shortcut['pid'] = BackendUtility::getRecord($shortcut['table'], $shortcut['recordid'])['pid'];
if ($queryParameters['edit'][$shortcut['table']][$shortcut['recordid']] === 'edit') {
$shortcut['type'] = 'edit';
$shortcutNamePrepend = htmlspecialchars($languageService->getLL('shortcut_edit'));
} elseif ($queryParameters['edit'][$shortcut['table']][$shortcut['recordid']] === 'new') {
$shortcut['type'] = 'new';
$shortcutNamePrepend = htmlspecialchars($languageService->getLL('shortcut_create'));
}
} else {
$shortcut['type'] = 'other';
$shortcut['table'] = '';
$shortcut['recordid'] = 0;
}
// Check if given id is a combined identifier
if (!empty($queryParameters['id']) && preg_match('/^[0-9]+:/', $queryParameters['id'])) {
try {
$resourceFactory = ResourceFactory::getInstance();
$resource = $resourceFactory->getObjectFromCombinedIdentifier($queryParameters['id']);
$shortcutName = trim($shortcutNamePrepend . ' ' . $resource->getName());
} catch (ResourceDoesNotExistException $e) {
}
} else {
// Lookup the title of this page and use it as default description
$pageId = (int)($shortcut['pid'] ?: ($shortcut['recordid'] ?: $this->getLinkedPageId($url)));
$page = false;
if ($pageId) {
$page = BackendUtility::getRecord('pages', $pageId);
}
if (!empty($page)) {
// Set the name to the title of the page
if ($shortcut['type'] === 'other') {
if (empty($shortcutName)) {
$shortcutName = $page['title'];
} else {
$shortcutName .= ' (' . $page['title'] . ')';
}
// Check if given id is a combined identifier
if (!empty($queryParameters['id']) && preg_match('/^[0-9]+:/', $queryParameters['id'])) {
try {
$resourceFactory = ResourceFactory::getInstance();
$resource = $resourceFactory->getObjectFromCombinedIdentifier($queryParameters['id']);
$shortcutName = trim($shortcutNamePrepend . ' ' . $resource->getName());
} catch (ResourceDoesNotExistException $e) {
}
} else {
// Lookup the title of this page and use it as default description
$pageId = (int)($shortcut['pid'] ?: ($shortcut['recordid'] ?: $this->getLinkedPageId($url)));
$page = false;
if ($pageId) {
$page = BackendUtility::getRecord('pages', $pageId);
}
if (!empty($page)) {
// Set the name to the title of the page
if ($shortcut['type'] === 'other') {
if (empty($shortcutName)) {
$shortcutName = $page['title'];
} else {
$shortcutName = $shortcutNamePrepend . ' ' .
$languageService->sL($GLOBALS['TCA'][$shortcut['table']]['ctrl']['title']) .
' (' . $page['title'] . ')';
$shortcutName .= ' (' . $page['title'] . ')';
}
} elseif ($shortcut['table'] !== '' && $shortcut['type'] !== 'other') {
} else {
$shortcutName = $shortcutNamePrepend . ' ' .
$languageService->sL($GLOBALS['TCA'][$shortcut['table']]['ctrl']['title']);
$languageService->sL($GLOBALS['TCA'][$shortcut['table']]['ctrl']['title']) .
' (' . $page['title'] . ')';
}
} elseif ($shortcut['table'] !== '' && $shortcut['type'] !== 'other') {
$shortcutName = $shortcutNamePrepend . ' ' .
$languageService->sL($GLOBALS['TCA'][$shortcut['table']]['ctrl']['title']);
}
return $this->tryAddingTheShortcut($response, $url, $shortcutName);
}
$shortcutCreated = $this->tryAddingTheShortcut($parsedBody['module'], $url, $shortcutName);
return new HtmlResponse($shortcutCreated);
}
/**
* Try to adding a shortcut
*
* @param ResponseInterface $response
* @param string $module
* @param string $url
* @param string $shortcutName
* @return ResponseInterface
* @throws \InvalidArgumentException
* @return string
*/
protected function tryAddingTheShortcut(ResponseInterface $response, $url, $shortcutName)
protected function tryAddingTheShortcut(string $module, $url, $shortcutName): string
{
$module = GeneralUtility::_POST('module');
$shortcutCreated = 'failed';
if (!empty($module) && !empty($url)) {
$shortcutCreated = 'alreadyExists';
......@@ -616,9 +604,7 @@ class ShortcutToolbarItem implements ToolbarItemInterface
$shortcutCreated = $this->addShortcut($url, $shortcutName, $module);
}
}
$response->getBody()->write($shortcutCreated);
return $response->withHeader('Content-Type', 'text/html; charset=utf-8');
return $shortcutCreated;
}
/**
......@@ -690,10 +676,9 @@ class ShortcutToolbarItem implements ToolbarItemInterface
* permissions to do so and saves the changes if everything is ok
*
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @return ResponseInterface
*/
public function saveFormAction(ServerRequestInterface $request, ResponseInterface $response)
public function saveFormAction(ServerRequestInterface $request): ResponseInterface
{
$parsedBody = $request->getParsedBody();
$queryParams = $request->getQueryParams();
......@@ -730,11 +715,9 @@ class ShortcutToolbarItem implements ToolbarItemInterface
}
if ($queryBuilder->execute() === 1) {
$response->getBody()->write($shortcutName);
} else {
$response->getBody()->write('failed');
return new HtmlResponse($shortcutName);
}
return $response->withHeader('Content-Type', 'text/html; charset=utf-8');
return new HtmlResponse('failed');
}
/**
......
......@@ -15,18 +15,20 @@ namespace TYPO3\CMS\Backend\Backend\ToolbarItems;
*/
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Toolbar\Enumeration\InformationStatus;
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Core\Core\Bootstrap;
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\CommandUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\StringUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\SignalSlot\Dispatcher;
use TYPO3\CMS\Fluid\View\StandaloneView;
/**
......@@ -66,7 +68,7 @@ class SystemInformationToolbarItem implements ToolbarItemInterface
protected $systemMessages = [];
/**
* @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
* @var Dispatcher
*/
protected $signalSlotDispatcher = null;
......@@ -107,15 +109,12 @@ class SystemInformationToolbarItem implements ToolbarItemInterface
/**
* Renders the menu for AJAX calls
*
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @return ResponseInterface
*/
public function renderMenuAction(ServerRequestInterface $request, ResponseInterface $response)
public function renderMenuAction(): ResponseInterface
{
$this->collectInformation();
$response->getBody()->write($this->getDropDown());
return $response->withHeader('Content-Type', 'text/html; charset=utf-8');
return new HtmlResponse($this->getDropDown());
}
/**
......@@ -411,13 +410,13 @@ class SystemInformationToolbarItem implements ToolbarItemInterface
/**
* Get the SignalSlot dispatcher
*
* @return \TYPO3\CMS\Extbase\SignalSlot\Dispatcher
* @return Dispatcher
*/
protected function getSignalSlotDispatcher()
{
if (!isset($this->signalSlotDispatcher)) {
$this->signalSlotDispatcher = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class)
->get(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class);
$this->signalSlotDispatcher = GeneralUtility::makeInstance(ObjectManager::class)
->get(Dispatcher::class);
}
return $this->signalSlotDispatcher;
}
......
......@@ -19,7 +19,6 @@ use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\FormProtection\FormProtectionFactory;
use TYPO3\CMS\Core\Http\JsonResponse;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* This is the ajax handler for backend login after timeout.
......@@ -49,7 +48,7 @@ class AjaxLoginController
} else {
$result = ['success' => false];
}
return GeneralUtility::makeInstance(JsonResponse::class, ['login' => $result]);
return new JsonResponse(['login' => $result]);
}
/**
......@@ -62,7 +61,7 @@ class AjaxLoginController
{
$backendUser = $this->getBackendUser();
$backendUser->logoff();
return GeneralUtility::makeInstance(JsonResponse::class, [
return new JsonResponse([
'logout' => [
'success' => !isset($backendUser->user['uid'])
]
......@@ -78,7 +77,7 @@ class AjaxLoginController
public function refreshAction(ServerRequestInterface $request): ResponseInterface
{
$this->getBackendUser()->checkAuthentication();
return GeneralUtility::makeInstance(JsonResponse::class, [
return new JsonResponse([
'refresh' => [
'success' => true
]
......@@ -111,7 +110,7 @@ class AjaxLoginController
// 120 is somewhat arbitrary to allow for a little room during the countdown and load times, etc.
$session['will_time_out'] = $GLOBALS['EXEC_TIME'] >= $ses_tstamp + $timeout - 120;
}
return GeneralUtility::makeInstance(JsonResponse::class, ['login' => $session]);
return new JsonResponse(['login' => $session]);
}
/**
......
......@@ -15,7 +15,6 @@ namespace TYPO3\CMS\Backend\Controller;
*/
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Domain\Repository\Module\BackendModuleRepository;
use TYPO3\CMS\Backend\Module\ModuleLoader;
use TYPO3\CMS\Backend\Routing\UriBuilder;
......@@ -25,6 +24,7 @@ use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Http\JsonResponse;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Page\PageRenderer;
......@@ -224,15 +224,12 @@ class BackendController
* Injects the request object for the current request or subrequest
* As this controller goes only through the render() method, it is rather simple for now
*
* @param ServerRequestInterface $request the current request
* @param ResponseInterface $response
* @return ResponseInterface the response with the content
*/
public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
public function mainAction(): ResponseInterface
{
$this->render();
$response->getBody()->write($this->content);
return $response;
return new HtmlResponse($this->content);
}
/**
......@@ -588,23 +585,21 @@ class BackendController
/**
* Returns the Module menu for the AJAX request
*
* @param ServerRequestInterface $request
* @return ResponseInterface
*/
public function getModuleMenu(ServerRequestInterface $request): ResponseInterface
public function getModuleMenu(): ResponseInterface
{
return GeneralUtility::makeInstance(JsonResponse::class, ['menu' => $this->generateModuleMenu()]);
return new JsonResponse(['menu' => $this->generateModuleMenu()]);
}
/**
* Returns the toolbar for the AJAX request
*
* @param ServerRequestInterface $request
* @return ResponseInterface
*/
public function getTopbar(ServerRequestInterface $request): ResponseInterface
public function getTopbar(): ResponseInterface
{
return GeneralUtility::makeInstance(JsonResponse::class, ['topbar' => $this->renderTopbar()]);
return new JsonResponse(['topbar' => $this->renderTopbar()]);
}
/**
......
......@@ -21,6 +21,7 @@ use TYPO3\CMS\Backend\Template\Components\ButtonBar;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\History\RecordHistoryStore;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\DiffUtility;
......@@ -81,10 +82,9 @@ class ElementHistoryController
* As this controller goes only through the main() method, it is rather simple for now
*
* @param ServerRequestInterface $request the current request
* @param ResponseInterface $response
* @return ResponseInterface the response with the content
*/
public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
public function mainAction(ServerRequestInterface $request): ResponseInterface
{
$this->request = $request;
$this->moduleTemplate->getDocHeaderComponent()->setMetaInformation([]);
......@@ -146,8 +146,7 @@ class ElementHistoryController
// Build the <body> for the module
$this->moduleTemplate->setContent($this->view->render());
$response->getBody()->write($this->moduleTemplate->renderContent());
return $response;
return new HtmlResponse($this->moduleTemplate->renderContent());
}
/**
......
......@@ -20,6 +20,7 @@ use TYPO3\CMS\Backend\Backend\Avatar\Avatar;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Resource\AbstractFile;
......@@ -188,15 +189,12 @@ class ElementInformationController
* As this controller goes only through the main() method, it is rather simple for now
*
* @param ServerRequestInterface $request the current request
* @param ResponseInterface $response
* @return ResponseInterface the response with the content
*/
public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
public function mainAction(ServerRequestInterface $request): ResponseInterface
{
$this->main();
$response->getBody()->write($this->moduleTemplate->renderContent());
return $response;
return new HtmlResponse($this->moduleTemplate->renderContent());
}
/**
......
......@@ -20,6 +20,7 @@ use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Tree\View\ContentMovingPagePositionMap;
use TYPO3\CMS\Backend\Tree\View\PageMovingPagePositionMap;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -119,16 +120,13 @@ class MoveElementController
* As this controller goes only through the main() method, it is rather simple for now
*
* @param ServerRequestInterface $request the current request
* @param ResponseInterface $response
* @return ResponseInterface the response with the content
*/
public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
public function mainAction(ServerRequestInterface $request): ResponseInterface
{
$this->main();
$this->moduleTemplate->setContent($this->content);
$response->getBody()->write($this->moduleTemplate->renderContent());
return $response;
return new HtmlResponse($this->moduleTemplate->renderContent());
}
/**
......
......@@ -22,6 +22,7 @@ use TYPO3\CMS\Backend\Tree\View\ContentCreationPagePositionMap;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\View\BackendLayoutView;
use TYPO3\CMS\Backend\Wizard\NewContentElementWizardHookInterface;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Service\DependencyOrderingService;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
......@@ -184,15 +185,13 @@ class NewContentElementController
* As this controller goes only through the main() method, it is rather simple for now
*
* @param ServerRequestInterface $request the current request
* @param ResponseInterface $response
* @return ResponseInterface the response with the content
*/
public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
public function mainAction(ServerRequestInterface $request): ResponseInterface
{
$this->prepareContent('window');
$this->moduleTemplate->setContent($this->content);
$response->getBody()->write($this->moduleTemplate->renderContent());
return $response;
return new HtmlResponse($this->moduleTemplate->renderContent());
}
/**
......@@ -200,14 +199,12 @@ class NewContentElementController
* As this controller goes only through the main() method, it is rather simple for now
*
* @param ServerRequestInterface $request the current request
* @param ResponseInterface $response
* @return ResponseInterface the response with the content
*/
public function wizardAction(ServerRequestInterface $request, ResponseInterface $response)
public function wizardAction(ServerRequestInterface $request): ResponseInterface
{
$this->prepareContent('list_frame');
$response->getBody()->write($this->content);
return $response;
return new HtmlResponse($this->content);
}
/**
......
......@@ -31,21 +31,21 @@ class ContextHelpAjaxController
* The main dispatcher function. Collect data and prepare HTML output.
*
* @param ServerRequestInterface $request
* @param ResponseInterface $response