diff --git a/typo3/sysext/about/Classes/Controller/AboutController.php b/typo3/sysext/about/Classes/Controller/AboutController.php index 6b7d91a7c850652123fd5139691795aca190dae5..88452a22cd62d992f8b3fd185ba0b6f8f0398bf6 100644 --- a/typo3/sysext/about/Classes/Controller/AboutController.php +++ b/typo3/sysext/about/Classes/Controller/AboutController.php @@ -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'); diff --git a/typo3/sysext/backend/Classes/Backend/ToolbarItems/ShortcutToolbarItem.php b/typo3/sysext/backend/Classes/Backend/ToolbarItems/ShortcutToolbarItem.php index 15bce3f834e59ab1a5073dd9b71eb007d31bf822..6c3332d01134e1a0fa3a168b2b2100056e0ba6a2 100644 --- a/typo3/sysext/backend/Classes/Backend/ToolbarItems/ShortcutToolbarItem.php +++ b/typo3/sysext/backend/Classes/Backend/ToolbarItems/ShortcutToolbarItem.php @@ -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'); } /** diff --git a/typo3/sysext/backend/Classes/Backend/ToolbarItems/SystemInformationToolbarItem.php b/typo3/sysext/backend/Classes/Backend/ToolbarItems/SystemInformationToolbarItem.php index c57201af0d8e9ab196c7add9b742803f7173a120..c4eed8bef7630524abefcd09c56e8bca873c15c6 100644 --- a/typo3/sysext/backend/Classes/Backend/ToolbarItems/SystemInformationToolbarItem.php +++ b/typo3/sysext/backend/Classes/Backend/ToolbarItems/SystemInformationToolbarItem.php @@ -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; } diff --git a/typo3/sysext/backend/Classes/Controller/AjaxLoginController.php b/typo3/sysext/backend/Classes/Controller/AjaxLoginController.php index 2a0996b4fa65f4424873d1d83a5a8f1aaa1ca902..5f4e916c7248451ee19aad8683f463822de3be8d 100644 --- a/typo3/sysext/backend/Classes/Controller/AjaxLoginController.php +++ b/typo3/sysext/backend/Classes/Controller/AjaxLoginController.php @@ -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]); } /** diff --git a/typo3/sysext/backend/Classes/Controller/BackendController.php b/typo3/sysext/backend/Classes/Controller/BackendController.php index 8b9185772b98a6888f48f4539fc3fb8d79d68fc9..140b5ebb04696a3254b63634f424b94e505fa2b8 100644 --- a/typo3/sysext/backend/Classes/Controller/BackendController.php +++ b/typo3/sysext/backend/Classes/Controller/BackendController.php @@ -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()]); } /** diff --git a/typo3/sysext/backend/Classes/Controller/ContentElement/ElementHistoryController.php b/typo3/sysext/backend/Classes/Controller/ContentElement/ElementHistoryController.php index 8e5293152e45166eeacef6f0c8b15b719d2fcf53..e8fcfedadd0defca7d07a95e9a8f8fdd293d0a64 100644 --- a/typo3/sysext/backend/Classes/Controller/ContentElement/ElementHistoryController.php +++ b/typo3/sysext/backend/Classes/Controller/ContentElement/ElementHistoryController.php @@ -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()); } /** diff --git a/typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php b/typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php index 812bfd4c2ae18c260dde3753834e18fe21bfa2fa..e34108a54dd1e311966fa78cd8897d8af9a48409 100644 --- a/typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php +++ b/typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php @@ -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()); } /** diff --git a/typo3/sysext/backend/Classes/Controller/ContentElement/MoveElementController.php b/typo3/sysext/backend/Classes/Controller/ContentElement/MoveElementController.php index 2aaca458a094d8827e6a664ee25fe75ee3e137ff..61ff8d523ef970115d3bab463709ee7a6ac1d661 100644 --- a/typo3/sysext/backend/Classes/Controller/ContentElement/MoveElementController.php +++ b/typo3/sysext/backend/Classes/Controller/ContentElement/MoveElementController.php @@ -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()); } /** diff --git a/typo3/sysext/backend/Classes/Controller/ContentElement/NewContentElementController.php b/typo3/sysext/backend/Classes/Controller/ContentElement/NewContentElementController.php index 52af9c1aafc93e9804a6255b03d95dde6b6c2302..0fb9787b4d5436da91bcac546be43be258212afb 100644 --- a/typo3/sysext/backend/Classes/Controller/ContentElement/NewContentElementController.php +++ b/typo3/sysext/backend/Classes/Controller/ContentElement/NewContentElementController.php @@ -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); } /** diff --git a/typo3/sysext/backend/Classes/Controller/ContextHelpAjaxController.php b/typo3/sysext/backend/Classes/Controller/ContextHelpAjaxController.php index 7076f1242a2fcc9a29d60b4d612cfae7ca258eb4..e1af5cdf5007a1e6d512f64e75fd0ab950cb2fe7 100644 --- a/typo3/sysext/backend/Classes/Controller/ContextHelpAjaxController.php +++ b/typo3/sysext/backend/Classes/Controller/ContextHelpAjaxController.php @@ -31,21 +31,21 @@ class ContextHelpAjaxController * The main dispatcher function. Collect data and prepare HTML output. * * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface + * @throws \RuntimeException */ - public function getHelpAction(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface + public function getHelpAction(ServerRequestInterface $request): ResponseInterface { $params = $request->getParsedBody()['params'] ?? $request->getQueryParams()['params']; - if ($params['action'] === 'getContextHelp') { - $result = $this->getContextHelp($params['table'], $params['field']); - return GeneralUtility::makeInstance(JsonResponse::class, [ - 'title' => $result['title'], - 'content' => $result['description'], - 'link' => $result['moreInfo'] - ]); + if ($params['action'] !== 'getContextHelp') { + throw new \RuntimeException('Action must be set to "getContextHelp"', 1518787887); } - return $response; + $result = $this->getContextHelp($params['table'], $params['field']); + return new JsonResponse([ + 'title' => $result['title'], + 'content' => $result['description'], + 'link' => $result['moreInfo'] + ]); } /** diff --git a/typo3/sysext/backend/Classes/Controller/ContextMenuController.php b/typo3/sysext/backend/Classes/Controller/ContextMenuController.php index 40fb5c27319299c0c38a606cb8057c893f0b8e1e..002144f2176c72c80e5d10eb8f8f4ffadff68cc9 100644 --- a/typo3/sysext/backend/Classes/Controller/ContextMenuController.php +++ b/typo3/sysext/backend/Classes/Controller/ContextMenuController.php @@ -52,7 +52,7 @@ class ContextMenuController if (!is_array($items)) { $items = []; } - return GeneralUtility::makeInstance(JsonResponse::class)->setPayload($items); + return (new JsonResponse())->setPayload($items); } /** @@ -70,7 +70,7 @@ class ContextMenuController $clipboard->cleanCurrent(); $clipboard->endClipboard(); - return GeneralUtility::makeInstance(JsonResponse::class)->setPayload([]); + return (new JsonResponse())->setPayload([]); } /** diff --git a/typo3/sysext/backend/Classes/Controller/DummyController.php b/typo3/sysext/backend/Classes/Controller/DummyController.php index 5635c19c8923072943479705d79a3ccef270a93b..c1d9c9458bffe815a6da5580f529435fe0955bbf 100644 --- a/typo3/sysext/backend/Classes/Controller/DummyController.php +++ b/typo3/sysext/backend/Classes/Controller/DummyController.php @@ -15,57 +15,30 @@ namespace TYPO3\CMS\Backend\Controller; */ use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; +use TYPO3\CMS\Backend\Template\DocumentTemplate; +use TYPO3\CMS\Core\Http\HtmlResponse; /** - * Script Class, creating the content for the dummy script - which is just blank output. + * '/empty' routing target returns dummy content. */ class DummyController { /** - * @var string - */ - public $content; - - /** - * Constructor - */ - public function __construct() - { - $GLOBALS['SOBE'] = $this; - } - - /** - * Injects the request object for the current request or subrequest - * As this controller goes only through the main() method, it is rather simple for now + * Return simple dummy content * - * @param ServerRequestInterface $request the current request - * @param ResponseInterface $response * @return ResponseInterface the response with the content */ - public function mainAction(ServerRequestInterface $request, ResponseInterface $response) - { - $this->main(); - - $response->getBody()->write($this->content); - return $response; - } - - /** - * Create content for the dummy script - outputting a blank page. - */ - public function main() + public function mainAction(): ResponseInterface { - // Start page - $this->content .= $this->getDocumentTemplate()->startPage('Dummy document'); - // End page: - $this->content .= $this->getDocumentTemplate()->endPage(); + $documentTemplate = $this->getDocumentTemplate(); + $content = $documentTemplate->startPage('Dummy document') . $documentTemplate->endPage(); + return new HtmlResponse($content); } /** * Returns an instance of DocumentTemplate * - * @return \TYPO3\CMS\Backend\Template\DocumentTemplate + * @return DocumentTemplate */ protected function getDocumentTemplate() { diff --git a/typo3/sysext/backend/Classes/Controller/EditDocumentController.php b/typo3/sysext/backend/Classes/Controller/EditDocumentController.php index cdf8e76a5720ce0ae5ef54f4eed1ba7ce8a0035b..61a646aa7c0536dd4b367ca99942aaf584093192 100644 --- a/typo3/sysext/backend/Classes/Controller/EditDocumentController.php +++ b/typo3/sysext/backend/Classes/Controller/EditDocumentController.php @@ -30,6 +30,7 @@ use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction; use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction; use TYPO3\CMS\Core\DataHandling\DataHandler; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Messaging\FlashMessageQueue; @@ -2076,10 +2077,9 @@ class EditDocumentController * Injects the request object for the current request or subrequest * * @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 { BackendUtility::lockRecords(); @@ -2094,8 +2094,7 @@ class EditDocumentController $this->init(); $this->main(); - $response->getBody()->write($this->moduleTemplate->renderContent()); - return $response; + return new HtmlResponse($this->moduleTemplate->renderContent()); } /** diff --git a/typo3/sysext/backend/Classes/Controller/File/CreateFolderController.php b/typo3/sysext/backend/Classes/Controller/File/CreateFolderController.php index d095945496b1ecbea748309603549604011ede9c..1bc22522f6e8455aeff15c8074501c3cdfbbb1ec 100644 --- a/typo3/sysext/backend/Classes/Controller/File/CreateFolderController.php +++ b/typo3/sysext/backend/Classes/Controller/File/CreateFolderController.php @@ -18,6 +18,7 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Backend\Template\ModuleTemplate; use TYPO3\CMS\Backend\Utility\BackendUtility; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException; use TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\OnlineMediaHelperRegistry; @@ -264,14 +265,12 @@ class CreateFolderController * Processes the request, currently everything is handled and put together via "main()" * * @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()); } /** diff --git a/typo3/sysext/backend/Classes/Controller/File/EditFileController.php b/typo3/sysext/backend/Classes/Controller/File/EditFileController.php index 7df8db6278d94c90bd18ef21db0a40dd7366a71b..349ea4eacb88f0551688c87bf7191a6c0fdcfd5a 100644 --- a/typo3/sysext/backend/Classes/Controller/File/EditFileController.php +++ b/typo3/sysext/backend/Classes/Controller/File/EditFileController.php @@ -21,6 +21,7 @@ use TYPO3\CMS\Backend\Form\NodeFactory; use TYPO3\CMS\Backend\Template\Components\ButtonBar; use TYPO3\CMS\Backend\Template\DocumentTemplate; use TYPO3\CMS\Backend\Template\ModuleTemplate; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Messaging\FlashMessageService; @@ -274,15 +275,12 @@ class EditFileController * Processes the request, currently everything is handled and put together via "main()" * * @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()); } /** diff --git a/typo3/sysext/backend/Classes/Controller/File/FileController.php b/typo3/sysext/backend/Classes/Controller/File/FileController.php index b8338f4fc24656d84c1e17801a9f0f4ba9128681..372ff42389088de80b70459672b4070e2cefc3b4 100644 --- a/typo3/sysext/backend/Classes/Controller/File/FileController.php +++ b/typo3/sysext/backend/Classes/Controller/File/FileController.php @@ -17,11 +17,14 @@ namespace TYPO3\CMS\Backend\Controller\File; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Backend\Utility\BackendUtility; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Http\JsonResponse; +use TYPO3\CMS\Core\Http\RedirectResponse; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Resource\DuplicationBehavior; use TYPO3\CMS\Core\Resource\Folder; +use TYPO3\CMS\Core\Resource\ResourceFactory; use TYPO3\CMS\Core\Utility\File\ExtendedFileUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -164,10 +167,9 @@ class FileController * As this controller goes only through the main() method, it just redirects to the given URL afterwards. * * @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(); @@ -189,12 +191,13 @@ class FileController $this->redirect = (string)$uriBuilder->buildUriFromRoute('file_edit', $urlParameters); } if ($this->redirect) { - return $response - ->withHeader('Location', GeneralUtility::locationHeaderUrl($this->redirect)) - ->withStatus(303); + return new RedirectResponse( + GeneralUtility::locationHeaderUrl($this->redirect), + 303 + ); } // empty response - return $response; + return new HtmlResponse(''); } /** @@ -204,34 +207,28 @@ class FileController * actual return value * * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface */ - public function processAjaxRequest(ServerRequestInterface $request, ResponseInterface $response) + public function processAjaxRequest(ServerRequestInterface $request): ResponseInterface { $this->main(); $errors = $this->fileProcessor->getErrorMessages(); if (!empty($errors)) { - $response->getBody()->write('<t3err>' . implode(',', $errors) . '</t3err>'); - $response = $response - ->withHeader('Content-Type', 'text/html; charset=utf-8') - ->withStatus(500, '(AJAX)'); - } else { - $flatResult = []; - foreach ($this->fileData as $action => $results) { - foreach ($results as $result) { - if (is_array($result)) { - foreach ($result as $subResult) { - $flatResult[$action][] = $this->flattenResultDataValue($subResult); - } - } else { - $flatResult[$action][] = $this->flattenResultDataValue($result); + return (new HtmlResponse('<t3err>' . implode(',', $errors) . '</t3err>'))->withStatus(500, '(AJAX)'); + } + $flatResult = []; + foreach ($this->fileData as $action => $results) { + foreach ($results as $result) { + if (is_array($result)) { + foreach ($result as $subResult) { + $flatResult[$action][] = $this->flattenResultDataValue($subResult); } + } else { + $flatResult[$action][] = $this->flattenResultDataValue($result); } } - return GeneralUtility::makeInstance(JsonResponse::class)->setPayload($flatResult); } - return $response; + return (new JsonResponse())->setPayload($flatResult); } /** @@ -240,13 +237,12 @@ class FileController * @param ServerRequestInterface $request * @return ResponseInterface */ - public function fileExistsInFolderAction(ServerRequestInterface $request) + public function fileExistsInFolderAction(ServerRequestInterface $request): ResponseInterface { $fileName = $request->getParsedBody()['fileName'] ?? $request->getQueryParams()['fileName']; $fileTarget = $request->getParsedBody()['fileTarget'] ?? $request->getQueryParams()['fileTarget']; - /** @var \TYPO3\CMS\Core\Resource\ResourceFactory $fileFactory */ - $fileFactory = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\ResourceFactory::class); + $fileFactory = GeneralUtility::makeInstance(ResourceFactory::class); /** @var Folder $fileTargetObject */ $fileTargetObject = $fileFactory->retrieveFileOrFolderObject($fileTarget); $processedFileName = $fileTargetObject->getStorage()->sanitizeFileName($fileName, $fileTargetObject); @@ -255,7 +251,7 @@ class FileController if ($fileTargetObject->hasFile($processedFileName)) { $result = $this->flattenResultDataValue($fileTargetObject->getStorage()->getFileInFolder($processedFileName, $fileTargetObject)); } - return GeneralUtility::makeInstance(JsonResponse::class)->setPayload($result); + return (new JsonResponse())->setPayload($result); } /** diff --git a/typo3/sysext/backend/Classes/Controller/File/FileUploadController.php b/typo3/sysext/backend/Classes/Controller/File/FileUploadController.php index f1e73b5ee60016eb6e65308bc9d87aa3688f56ec..0bbd63e81914819028c5a67aeafa4a5c98e9e6fe 100644 --- a/typo3/sysext/backend/Classes/Controller/File/FileUploadController.php +++ b/typo3/sysext/backend/Classes/Controller/File/FileUploadController.php @@ -17,6 +17,7 @@ namespace TYPO3\CMS\Backend\Controller\File; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Backend\Template\ModuleTemplate; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException; use TYPO3\CMS\Core\Resource\ResourceFactory; @@ -210,15 +211,12 @@ class FileUploadController * Processes the request, currently everything is handled and put together via "main()" * * @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()); } /** diff --git a/typo3/sysext/backend/Classes/Controller/File/RenameFileController.php b/typo3/sysext/backend/Classes/Controller/File/RenameFileController.php index d5fa13f3dcf88f88b859e47f79b380d70d6e0e8c..21f2992cf7ee12c56e51245f05638f0b11313b17 100644 --- a/typo3/sysext/backend/Classes/Controller/File/RenameFileController.php +++ b/typo3/sysext/backend/Classes/Controller/File/RenameFileController.php @@ -18,6 +18,7 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Backend\Template\Components\ButtonBar; use TYPO3\CMS\Backend\Template\ModuleTemplate; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Resource\DuplicationBehavior; use TYPO3\CMS\Core\Resource\File; @@ -218,15 +219,12 @@ class RenameFileController /** * Processes the request, currently everything is handled and put together via "main()" * - * @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()); } /** diff --git a/typo3/sysext/backend/Classes/Controller/File/ReplaceFileController.php b/typo3/sysext/backend/Classes/Controller/File/ReplaceFileController.php index 2e7dddff71fb730388439e94f2f533a872e9e134..12ba4c2844c20576db83bfdb1435ddcdf26a5733 100644 --- a/typo3/sysext/backend/Classes/Controller/File/ReplaceFileController.php +++ b/typo3/sysext/backend/Classes/Controller/File/ReplaceFileController.php @@ -17,6 +17,7 @@ namespace TYPO3\CMS\Backend\Controller\File; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Backend\Template\ModuleTemplate; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException; @@ -192,15 +193,12 @@ class ReplaceFileController * Processes the request, currently everything is handled and put together via "main()" * * @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()); } /** diff --git a/typo3/sysext/backend/Classes/Controller/FileSystemNavigationFrameController.php b/typo3/sysext/backend/Classes/Controller/FileSystemNavigationFrameController.php index 5b069f7261d1a99f9f4e6a335bbdff8c01044187..785fee5fc2cfc65dc5e8de9a13f6a00ccd67b703 100644 --- a/typo3/sysext/backend/Classes/Controller/FileSystemNavigationFrameController.php +++ b/typo3/sysext/backend/Classes/Controller/FileSystemNavigationFrameController.php @@ -20,6 +20,7 @@ use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\Template\Components\ButtonBar; use TYPO3\CMS\Backend\Template\ModuleTemplate; use TYPO3\CMS\Backend\Tree\View\ElementBrowserFolderTreeView; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Http\JsonResponse; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; @@ -77,16 +78,13 @@ class FileSystemNavigationFrameController /** * @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->initPage(); $this->main(); - - $response->getBody()->write($this->content); - return $response; + return new HtmlResponse($this->content); } /** @@ -226,17 +224,16 @@ class FileSystemNavigationFrameController * Called by an AJAX Route, see AjaxRequestHandler * * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface */ - public function ajaxExpandCollapse(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface + public function ajaxExpandCollapse(ServerRequestInterface $request): ResponseInterface { $this->init(); $tree = $this->foldertree->getBrowsableTree(); if ($this->foldertree->getAjaxStatus() === false) { - return $response->withStatus(500); + return new HtmlResponse('', 500); } - return GeneralUtility::makeInstance(JsonResponse::class, [$tree]); + return new JsonResponse([$tree]); } /** diff --git a/typo3/sysext/backend/Classes/Controller/FlashMessageController.php b/typo3/sysext/backend/Classes/Controller/FlashMessageController.php index 7d85b8cf5190ff8a0914f832f7947fa10741c361..9bb273672e61cf6050dcbed450d9937decf2e4a3 100644 --- a/typo3/sysext/backend/Classes/Controller/FlashMessageController.php +++ b/typo3/sysext/backend/Classes/Controller/FlashMessageController.php @@ -16,7 +16,6 @@ namespace TYPO3\CMS\Backend\Controller; */ use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Core\Http\JsonResponse; use TYPO3\CMS\Core\Messaging\FlashMessageService; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -29,10 +28,9 @@ class FlashMessageController /** * Renders the FlashMessages from queue and returns them as JSON. * - * @param ServerRequestInterface $request * @return ResponseInterface */ - public function getQueuedFlashMessagesAction(ServerRequestInterface $request): ResponseInterface + public function getQueuedFlashMessagesAction(): ResponseInterface { $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier(); @@ -47,6 +45,6 @@ class FlashMessageController ]; } - return GeneralUtility::makeInstance(JsonResponse::class)->setPayload($messages); + return (new JsonResponse())->setPayload($messages); } } diff --git a/typo3/sysext/backend/Classes/Controller/FormFlexAjaxController.php b/typo3/sysext/backend/Classes/Controller/FormFlexAjaxController.php index 9a0521e999355ba857f15a3325d0fc38b7326fb7..47db685291f7297152630c47ef799c6b96813672 100644 --- a/typo3/sysext/backend/Classes/Controller/FormFlexAjaxController.php +++ b/typo3/sysext/backend/Classes/Controller/FormFlexAjaxController.php @@ -180,6 +180,6 @@ class FormFlexAjaxController extends AbstractFormEngineAjaxController $requireJsModule = $this->createExecutableStringRepresentationOfRegisteredRequireJsModules($newContainerResult); $jsonResult['scriptCall'] = array_merge($requireJsModule, $jsonResult['scriptCall']); - return GeneralUtility::makeInstance(JsonResponse::class, $jsonResult); + return new JsonResponse($jsonResult); } } diff --git a/typo3/sysext/backend/Classes/Controller/FormInlineAjaxController.php b/typo3/sysext/backend/Classes/Controller/FormInlineAjaxController.php index fec04f11dfd7b6da29a89c21aff682342a731fe7..37f3e6ae04e46183d66720cecfba36414bfe7e6d 100644 --- a/typo3/sysext/backend/Classes/Controller/FormInlineAjaxController.php +++ b/typo3/sysext/backend/Classes/Controller/FormInlineAjaxController.php @@ -162,7 +162,7 @@ class FormInlineAjaxController extends AbstractFormEngineAjaxController // Fade out and fade in the new record in the browser view to catch the user's eye $jsonArray['scriptCall'][] = 'inline.fadeOutFadeIn(' . GeneralUtility::quoteJSvalue($objectId . '_div') . ');'; - return GeneralUtility::makeInstance(JsonResponse::class, $jsonArray); + return new JsonResponse($jsonArray); } /** @@ -243,7 +243,7 @@ class FormInlineAjaxController extends AbstractFormEngineAjaxController $jsonArray['scriptCall'][] = 'inline.collapseAllRecords(' . GeneralUtility::quoteJSvalue($objectId) . ',' . GeneralUtility::quoteJSvalue($objectPrefix) . ',\'' . (int)$child['uid'] . '\');'; } - return GeneralUtility::makeInstance(JsonResponse::class, $jsonArray); + return new JsonResponse($jsonArray); } /** @@ -401,7 +401,7 @@ class FormInlineAjaxController extends AbstractFormEngineAjaxController . ', json.data);'; } } - return GeneralUtility::makeInstance(JsonResponse::class)->setPayload($jsonArray); + return new JsonResponse($jsonArray); } /** @@ -450,7 +450,7 @@ class FormInlineAjaxController extends AbstractFormEngineAjaxController $backendUser->writeUC(); } } - return GeneralUtility::makeInstance(JsonResponse::class)->setPayload([]); + return (new JsonResponse())->setPayload([]); } /** diff --git a/typo3/sysext/backend/Classes/Controller/FormSelectTreeAjaxController.php b/typo3/sysext/backend/Classes/Controller/FormSelectTreeAjaxController.php index 8a6e44724b538c40978c0af0b128747e26fecab8..f33f6fb0a51d60452b63378d203a23f0290b4e3b 100644 --- a/typo3/sysext/backend/Classes/Controller/FormSelectTreeAjaxController.php +++ b/typo3/sysext/backend/Classes/Controller/FormSelectTreeAjaxController.php @@ -179,6 +179,6 @@ class FormSelectTreeAjaxController } else { $treeData = $formData['processedTca']['columns'][$fieldName]['config']['items']; } - return GeneralUtility::makeInstance(JsonResponse::class)->setPayload($treeData); + return (new JsonResponse())->setPayload($treeData); } } diff --git a/typo3/sysext/backend/Classes/Controller/LinkBrowserController.php b/typo3/sysext/backend/Classes/Controller/LinkBrowserController.php index a66951861ea89d12f2b8c8e41a3f32919832a585..572a803b46c2ac71ab3a5dfc84ab4668d4329ae4 100644 --- a/typo3/sysext/backend/Classes/Controller/LinkBrowserController.php +++ b/typo3/sysext/backend/Classes/Controller/LinkBrowserController.php @@ -93,7 +93,7 @@ class LinkBrowserController extends AbstractLinkBrowserController } $typoLink = GeneralUtility::makeInstance(TypoLinkCodecService::class)->encode($typoLinkParts); - return GeneralUtility::makeInstance(JsonResponse::class, ['typoLink' => $typoLink]); + return new JsonResponse(['typoLink' => $typoLink]); } /** diff --git a/typo3/sysext/backend/Classes/Controller/LiveSearchController.php b/typo3/sysext/backend/Classes/Controller/LiveSearchController.php index baa69f1bfda343a63d7962a28848ac1210548e1e..4623a4dc2ded6f9c982b9bf9a5c40ce5d8eb17a6 100644 --- a/typo3/sysext/backend/Classes/Controller/LiveSearchController.php +++ b/typo3/sysext/backend/Classes/Controller/LiveSearchController.php @@ -59,6 +59,6 @@ class LiveSearchController $searchResults[] = $item; } } - return GeneralUtility::makeInstance(JsonResponse::class)->setPayload($searchResults); + return (new JsonResponse())->setPayload($searchResults); } } diff --git a/typo3/sysext/backend/Classes/Controller/LoginController.php b/typo3/sysext/backend/Classes/Controller/LoginController.php index aa99e82ed938ec23e0eaf081409ccbedb2721bf1..f6ae7ae6efa8a6ff858e444c137a36ef992cca3a 100644 --- a/typo3/sysext/backend/Classes/Controller/LoginController.php +++ b/typo3/sysext/backend/Classes/Controller/LoginController.php @@ -25,6 +25,7 @@ use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\FormProtection\BackendFormProtection; use TYPO3\CMS\Core\FormProtection\FormProtectionFactory; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Localization\Locales; use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -139,14 +140,11 @@ class LoginController * As this controller goes only through the main() method, it is rather simple for now * * @param ServerRequestInterface $request the current request - * @param ResponseInterface $response the current response * @return ResponseInterface the finished response with the content */ - public function formAction(ServerRequestInterface $request, ResponseInterface $response) + public function formAction(ServerRequestInterface $request): ResponseInterface { - $content = $this->main(); - $response->getBody()->write($content); - return $response; + return new HtmlResponse($this->main()); } /** diff --git a/typo3/sysext/backend/Classes/Controller/LoginFramesetController.php b/typo3/sysext/backend/Classes/Controller/LoginFramesetController.php index cb1baf950125d9e8b74d0ff6e169557560439c7a..5228574c80791e4c793bcf07c2139ff266419e68 100644 --- a/typo3/sysext/backend/Classes/Controller/LoginFramesetController.php +++ b/typo3/sysext/backend/Classes/Controller/LoginFramesetController.php @@ -16,6 +16,7 @@ namespace TYPO3\CMS\Backend\Controller; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -42,14 +43,12 @@ class LoginFramesetController * As this controller goes only through the main() method, it is rather simple for now * * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface */ - public function mainAction(ServerRequestInterface $request, ResponseInterface $response) + public function mainAction(ServerRequestInterface $request): ResponseInterface { $this->main(); - $response->getBody()->write($this->content); - return $response; + return new HtmlResponse($this->content); } /** diff --git a/typo3/sysext/backend/Classes/Controller/LogoutController.php b/typo3/sysext/backend/Classes/Controller/LogoutController.php index 0979dfcdbdea2a55091ab9e05f8d5680553e582b..b4fe92507f4b84f97f77c661e7e9912c6a384e8a 100644 --- a/typo3/sysext/backend/Classes/Controller/LogoutController.php +++ b/typo3/sysext/backend/Classes/Controller/LogoutController.php @@ -16,7 +16,9 @@ namespace TYPO3\CMS\Backend\Controller; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Core\FormProtection\FormProtectionFactory; +use TYPO3\CMS\Core\Http\RedirectResponse; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -31,23 +33,19 @@ class LogoutController * This will be split up in an abstract controller once proper routing/dispatcher is in place. * * @param ServerRequestInterface $request the current request - * @param ResponseInterface $response * @return ResponseInterface the response with the content */ - public function logoutAction(ServerRequestInterface $request, ResponseInterface $response) + public function logoutAction(ServerRequestInterface $request): ResponseInterface { $this->logout(); $redirectUrl = $request->getParsedBody()['redirect'] ?? $request->getQueryParams()['redirect']; $redirectUrl = GeneralUtility::sanitizeLocalUrl($redirectUrl); if (empty($redirectUrl)) { - /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */ - $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class); + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $redirectUrl = (string)$uriBuilder->buildUriFromRoute('login', [], $uriBuilder::ABSOLUTE_URL); } - return $response - ->withStatus(303) - ->withHeader('Location', GeneralUtility::locationHeaderUrl($redirectUrl)); + return new RedirectResponse(GeneralUtility::locationHeaderUrl($redirectUrl), 303); } /** diff --git a/typo3/sysext/backend/Classes/Controller/NewRecordController.php b/typo3/sysext/backend/Classes/Controller/NewRecordController.php index 62a765c1ac863f0b4e0192e6440aac4262752948..a4c3900febedb0de77ce221bbc5424f1ec43aaa8 100644 --- a/typo3/sysext/backend/Classes/Controller/NewRecordController.php +++ b/typo3/sysext/backend/Classes/Controller/NewRecordController.php @@ -24,6 +24,7 @@ use TYPO3\CMS\Backend\Tree\View\PagePositionMap; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Type\Bitmask\Permission; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; @@ -248,15 +249,12 @@ class NewRecordController * 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()); } /** diff --git a/typo3/sysext/backend/Classes/Controller/OnlineMediaController.php b/typo3/sysext/backend/Classes/Controller/OnlineMediaController.php index 23b5dc4093e1b6e7a0cabda0e22466615b0097eb..a61cd120da69cb01dc553ab567b6e2ec044ad990 100644 --- a/typo3/sysext/backend/Classes/Controller/OnlineMediaController.php +++ b/typo3/sysext/backend/Classes/Controller/OnlineMediaController.php @@ -16,6 +16,7 @@ namespace TYPO3\CMS\Backend\Controller; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Http\JsonResponse; use TYPO3\CMS\Core\Http\RedirectResponse; use TYPO3\CMS\Core\Localization\LanguageService; @@ -34,10 +35,9 @@ class OnlineMediaController /** * AJAX endpoint for storing the URL as a sys_file record * - * @param ServerRequestInterface $request * @return ResponseInterface */ - public function createAction(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface + public function createAction(ServerRequestInterface $request): ResponseInterface { $url = $request->getParsedBody()['url']; $targetFolderIdentifier = $request->getParsedBody()['targetFolder']; @@ -51,9 +51,9 @@ class OnlineMediaController } else { $data['error'] = $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:online_media.error.invalid_url'); } - return GeneralUtility::makeInstance(JsonResponse::class, $data); + return new JsonResponse($data); } - return $response; + return new HtmlResponse(''); } /** @@ -61,8 +61,9 @@ class OnlineMediaController * * @param ServerRequestInterface $request * @return ResponseInterface + * @throws \RuntimeException */ - public function mainAction(ServerRequestInterface $request) + public function mainAction(ServerRequestInterface $request): ResponseInterface { $files = $request->getParsedBody()['data']; $redirect = $request->getParsedBody()['redirect']; diff --git a/typo3/sysext/backend/Classes/Controller/Page/LocalizationController.php b/typo3/sysext/backend/Classes/Controller/Page/LocalizationController.php index 548acdc2bd2c57dbbf3322268351e012b57f136c..8650faaadd33f58579a938634afa19b2e56325aa 100644 --- a/typo3/sysext/backend/Classes/Controller/Page/LocalizationController.php +++ b/typo3/sysext/backend/Classes/Controller/Page/LocalizationController.php @@ -20,6 +20,7 @@ use TYPO3\CMS\Backend\Configuration\TranslationConfigurationProvider; use TYPO3\CMS\Backend\Domain\Repository\Localization\LocalizationRepository; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\DataHandling\DataHandler; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Http\JsonResponse; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; @@ -64,15 +65,13 @@ class LocalizationController * Get used languages in a colPos of a page * * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface */ - public function getUsedLanguagesInPageAndColumn(ServerRequestInterface $request, ResponseInterface $response) + public function getUsedLanguagesInPageAndColumn(ServerRequestInterface $request): ResponseInterface { $params = $request->getQueryParams(); if (!isset($params['pageId'], $params['colPos'], $params['languageId'])) { - $response = $response->withStatus(400); - return $response; + return new HtmlResponse('', 400); } $pageId = (int)$params['pageId']; @@ -111,22 +110,20 @@ class LocalizationController } } - return GeneralUtility::makeInstance(JsonResponse::class)->setPayload($availableLanguages); + return (new JsonResponse())->setPayload($availableLanguages); } /** * Get a prepared summary of records being translated * * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface */ - public function getRecordLocalizeSummary(ServerRequestInterface $request, ResponseInterface $response) + public function getRecordLocalizeSummary(ServerRequestInterface $request): ResponseInterface { $params = $request->getQueryParams(); if (!isset($params['pageId'], $params['colPos'], $params['destLanguageId'], $params['languageId'])) { - $response = $response->withStatus(400); - return $response; + return new HtmlResponse('', 400); } $records = []; @@ -150,26 +147,22 @@ class LocalizationController ]; } - return GeneralUtility::makeInstance(JsonResponse::class)->setPayload($records); + return (new JsonResponse())->setPayload($records); } /** * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface */ - public function localizeRecords(ServerRequestInterface $request, ResponseInterface $response) + public function localizeRecords(ServerRequestInterface $request): ResponseInterface { $params = $request->getQueryParams(); if (!isset($params['pageId'], $params['srcLanguageId'], $params['destLanguageId'], $params['action'], $params['uidList'])) { - $response = $response->withStatus(400); - return $response; + return new HtmlResponse('', 400); } if ($params['action'] !== static::ACTION_COPY && $params['action'] !== static::ACTION_LOCALIZE) { - $response->getBody()->write('Invalid action "' . $params['action'] . '" called.'); - $response = $response->withStatus(400); - return $response; + return new HtmlResponse('Invalid action "' . $params['action'] . '" called.', 400); } // Filter transmitted but invalid uids @@ -183,7 +176,7 @@ class LocalizationController $this->process($params); - return GeneralUtility::makeInstance(JsonResponse::class)->setPayload([]); + return (new JsonResponse())->setPayload([]); } /** diff --git a/typo3/sysext/backend/Classes/Controller/Page/NewMultiplePagesController.php b/typo3/sysext/backend/Classes/Controller/Page/NewMultiplePagesController.php index d25a21d529133692ad8e46bb36199fe495bc943e..2fe38892c19369426ddd1af31e6e54122307f1a8 100644 --- a/typo3/sysext/backend/Classes/Controller/Page/NewMultiplePagesController.php +++ b/typo3/sysext/backend/Classes/Controller/Page/NewMultiplePagesController.php @@ -23,6 +23,7 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; use TYPO3\CMS\Core\DataHandling\DataHandler; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Localization\LanguageService; @@ -57,10 +58,9 @@ class NewMultiplePagesController * Main function Handling input variables and rendering main view * * @param $request ServerRequestInterface - * @param $response ResponseInterface * @return ResponseInterface Response */ - public function mainAction(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface + public function mainAction(ServerRequestInterface $request): ResponseInterface { $backendUser = $this->getBackendUser(); $pageUid = (int)$request->getQueryParams()['id']; @@ -70,8 +70,7 @@ class NewMultiplePagesController if (!is_array($pageRecord)) { // User has no permission on parent page, should not happen, just render an empty page $this->moduleTemplate->setContent(''); - $response->getBody()->write($this->moduleTemplate->renderContent()); - return $response; + return new HtmlResponse($this->moduleTemplate->renderContent()); } // Doc header handling @@ -130,8 +129,7 @@ class NewMultiplePagesController } $this->moduleTemplate->setContent($view->render()); - $response->getBody()->write($this->moduleTemplate->renderContent()); - return $response; + return new HtmlResponse($this->moduleTemplate->renderContent()); } /** diff --git a/typo3/sysext/backend/Classes/Controller/Page/SortSubPagesController.php b/typo3/sysext/backend/Classes/Controller/Page/SortSubPagesController.php index db051643819b36dfdd0e3c40411b4c2e780d749a..fac05ced3aa54d70733084be988d5d76fb885b78 100644 --- a/typo3/sysext/backend/Classes/Controller/Page/SortSubPagesController.php +++ b/typo3/sysext/backend/Classes/Controller/Page/SortSubPagesController.php @@ -23,6 +23,7 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; use TYPO3\CMS\Core\DataHandling\DataHandler; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Localization\LanguageService; @@ -56,10 +57,9 @@ class SortSubPagesController * Main function Handling input variables and rendering main view * * @param $request ServerRequestInterface - * @param $response ResponseInterface * @return ResponseInterface Response */ - public function mainAction(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface + public function mainAction(ServerRequestInterface $request): ResponseInterface { $backendUser = $this->getBackendUser(); $parentPageUid = (int)$request->getQueryParams()['id']; @@ -69,8 +69,7 @@ class SortSubPagesController if (!is_array($pageInformation)) { // User has no permission on parent page, should not happen, just render an empty page $this->moduleTemplate->setContent(''); - $response->getBody()->write($this->moduleTemplate->renderContent()); - return $response; + return new HtmlResponse($this->moduleTemplate->renderContent()); } // Doc header handling @@ -133,8 +132,7 @@ class SortSubPagesController } $this->moduleTemplate->setContent($view->render()); - $response->getBody()->write($this->moduleTemplate->renderContent()); - return $response; + return new HtmlResponse($this->moduleTemplate->renderContent()); } /** diff --git a/typo3/sysext/backend/Classes/Controller/Page/TreeController.php b/typo3/sysext/backend/Classes/Controller/Page/TreeController.php index 5ededca0cb4312371b9e4ce0442de430abf50020..88478d3fc4afb00f638afca24e7704e979407468 100644 --- a/typo3/sysext/backend/Classes/Controller/Page/TreeController.php +++ b/typo3/sysext/backend/Classes/Controller/Page/TreeController.php @@ -122,7 +122,7 @@ class TreeController 'temporaryMountPoint' => $this->getMountPointPath((int)($this->getBackendUser()->uc['pageTree_temporaryMountPoint'] ?? 0)), ]; - return GeneralUtility::makeInstance(JsonResponse::class, $configuration); + return new JsonResponse($configuration); } /** @@ -197,7 +197,7 @@ class TreeController $items = array_merge($items, $this->pagesToFlatArray($page, (int)$page['uid'])); } - return GeneralUtility::makeInstance(JsonResponse::class, $items); + return new JsonResponse($items); } /** @@ -222,7 +222,7 @@ class TreeController $response = [ 'mountPointPath' => $this->getMountPointPath($pid) ]; - return GeneralUtility::makeInstance(JsonResponse::class, $response); + return new JsonResponse($response); } /** diff --git a/typo3/sysext/backend/Classes/Controller/PageLayoutController.php b/typo3/sysext/backend/Classes/Controller/PageLayoutController.php index 23549fdad8d12a43b91784a7603cc470273af3a3..ced13cd02f7ac008491094c9e3b09bafbf99df3f 100644 --- a/typo3/sysext/backend/Classes/Controller/PageLayoutController.php +++ b/typo3/sysext/backend/Classes/Controller/PageLayoutController.php @@ -28,6 +28,7 @@ use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction; use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction; use TYPO3\CMS\Core\DataHandling\DataHandler; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Page\PageRenderer; @@ -668,17 +669,15 @@ class PageLayoutController * 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 { $GLOBALS['SOBE'] = $this; $this->init(); $this->clearCache(); $this->main(); - $response->getBody()->write($this->moduleTemplate->renderContent()); - return $response; + return new HtmlResponse($this->moduleTemplate->renderContent()); } /** diff --git a/typo3/sysext/backend/Classes/Controller/SimpleDataHandlerController.php b/typo3/sysext/backend/Classes/Controller/SimpleDataHandlerController.php index d222d9ec564ce6a8b21c406c7f743b963aeaa11b..34268d9a2658a90a6af7b7621ede79205a8389c9 100644 --- a/typo3/sysext/backend/Classes/Controller/SimpleDataHandlerController.php +++ b/typo3/sysext/backend/Classes/Controller/SimpleDataHandlerController.php @@ -19,7 +19,9 @@ use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Backend\Clipboard\Clipboard; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\DataHandling\DataHandler; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Http\JsonResponse; +use TYPO3\CMS\Core\Http\RedirectResponse; use TYPO3\CMS\Core\Messaging\AbstractMessage; use TYPO3\CMS\Core\Messaging\FlashMessageService; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -192,10 +194,9 @@ class SimpleDataHandlerController * As this controller goes only through the main() method, it just redirects to the given URL afterwards. * * @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->initClipboard(); $this->main(); @@ -203,11 +204,9 @@ class SimpleDataHandlerController // Write errors to flash message queue $this->tce->printLogErrorMessages(); if ($this->redirect) { - $response = $response - ->withHeader('Location', GeneralUtility::locationHeaderUrl($this->redirect)) - ->withStatus(303); + return new RedirectResponse(GeneralUtility::locationHeaderUrl($this->redirect), 303); } - return $response; + return new HtmlResponse(''); } /** @@ -247,7 +246,7 @@ class SimpleDataHandlerController } } } - return GeneralUtility::makeInstance(JsonResponse::class, $content); + return new JsonResponse($content); } /** diff --git a/typo3/sysext/backend/Classes/Controller/UserSettingsController.php b/typo3/sysext/backend/Classes/Controller/UserSettingsController.php index ad104fb32ce1c8844a43f424a4bdd8283223f1dd..3f603f2abbb3a11756cbfa29087fca4d195f57ba 100644 --- a/typo3/sysext/backend/Classes/Controller/UserSettingsController.php +++ b/typo3/sysext/backend/Classes/Controller/UserSettingsController.php @@ -41,7 +41,7 @@ class UserSettingsController $value = $request->getParsedBody()['value'] ?? $request->getQueryParams()['value']; $content = $this->process($action, $key, $value); - return GeneralUtility::makeInstance(JsonResponse::class)->setPayload($content); + return (new JsonResponse())->setPayload($content); } /** diff --git a/typo3/sysext/backend/Classes/Controller/Wizard/AddController.php b/typo3/sysext/backend/Classes/Controller/Wizard/AddController.php index 234e6fc8c2da91893e0ebb476cfff391ff6951a8..9409830391d46a70e1a46e81c9413483c54a94ae 100644 --- a/typo3/sysext/backend/Classes/Controller/Wizard/AddController.php +++ b/typo3/sysext/backend/Classes/Controller/Wizard/AddController.php @@ -21,6 +21,7 @@ use TYPO3\CMS\Backend\Form\FormDataGroup\TcaDatabaseRecord; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools; use TYPO3\CMS\Core\DataHandling\DataHandler; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\HttpUtility; use TYPO3\CMS\Core\Utility\MathUtility; @@ -155,13 +156,12 @@ class AddController extends AbstractWizardController * As this controller goes only through the main() method, it is rather simple for now * * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface */ - public function mainAction(ServerRequestInterface $request, ResponseInterface $response) + public function mainAction(ServerRequestInterface $request): ResponseInterface { $this->main(); - return $response; + return new HtmlResponse(''); } /** diff --git a/typo3/sysext/backend/Classes/Controller/Wizard/EditController.php b/typo3/sysext/backend/Classes/Controller/Wizard/EditController.php index 6b8884f547b4fbffe9206483ba540ef74dffab2e..553c84c58ae94544544a6c2bb88a30921f6e8a87 100644 --- a/typo3/sysext/backend/Classes/Controller/Wizard/EditController.php +++ b/typo3/sysext/backend/Classes/Controller/Wizard/EditController.php @@ -17,6 +17,7 @@ namespace TYPO3\CMS\Backend\Controller\Wizard; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Core\Database\RelationHandler; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\HttpUtility; use TYPO3\CMS\Core\Utility\MathUtility; @@ -73,14 +74,12 @@ class EditController extends AbstractWizardController * As this controller goes only through the main() method, it is rather simple for now * * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface */ - public function mainAction(ServerRequestInterface $request, ResponseInterface $response) + public function mainAction(ServerRequestInterface $request): ResponseInterface { $content = $this->main(); - $response->getBody()->write($content); - return $response; + return new HtmlResponse($content); } /** diff --git a/typo3/sysext/backend/Classes/Controller/Wizard/ListController.php b/typo3/sysext/backend/Classes/Controller/Wizard/ListController.php index d08fab80f4708dff42521496930915cf958796c0..344724cdc7b869f62d0e3864fd2743e1f90686e2 100644 --- a/typo3/sysext/backend/Classes/Controller/Wizard/ListController.php +++ b/typo3/sysext/backend/Classes/Controller/Wizard/ListController.php @@ -17,6 +17,7 @@ namespace TYPO3\CMS\Backend\Controller\Wizard; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Backend\Utility\BackendUtility; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\HttpUtility; @@ -68,13 +69,12 @@ class ListController extends AbstractWizardController * As this controller goes only through the main() method, it is rather simple for now * * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface */ - public function mainAction(ServerRequestInterface $request, ResponseInterface $response) + public function mainAction(ServerRequestInterface $request): ResponseInterface { $this->main(); - return $response; + return new HtmlResponse(''); } /** diff --git a/typo3/sysext/backend/Classes/Controller/Wizard/SuggestWizardController.php b/typo3/sysext/backend/Classes/Controller/Wizard/SuggestWizardController.php index 8ec88aba8e8402a6d3196d683c48abc25815bb58..f1ab5fcbf935908e256843f2ada15c364550a06a 100644 --- a/typo3/sysext/backend/Classes/Controller/Wizard/SuggestWizardController.php +++ b/typo3/sysext/backend/Classes/Controller/Wizard/SuggestWizardController.php @@ -161,7 +161,7 @@ class SuggestWizardController $maxItems = min(count($resultRows), $maxItems); array_splice($resultRows, $maxItems); - return GeneralUtility::makeInstance(JsonResponse::class)->setPayload(array_values($resultRows)); + return (new JsonResponse())->setPayload(array_values($resultRows)); } /** diff --git a/typo3/sysext/backend/Classes/Controller/Wizard/TableController.php b/typo3/sysext/backend/Classes/Controller/Wizard/TableController.php index 5b229612908670c8a4c57f01b5a6576067851fe2..9cd3f6140cc38e26b25715bc614c6980ccb333a4 100644 --- a/typo3/sysext/backend/Classes/Controller/Wizard/TableController.php +++ b/typo3/sysext/backend/Classes/Controller/Wizard/TableController.php @@ -21,6 +21,7 @@ use TYPO3\CMS\Backend\Template\ModuleTemplate; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools; use TYPO3\CMS\Core\DataHandling\DataHandler; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -145,14 +146,12 @@ class TableController extends AbstractWizardController * As this controller goes only through the main() method, it is rather simple for now * * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface */ - 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()); } /** diff --git a/typo3/sysext/backend/Classes/Form/Wizard/ImageManipulationWizard.php b/typo3/sysext/backend/Classes/Form/Wizard/ImageManipulationWizard.php index 0b10301a7539c63f16f68d3943ec92594fab82a7..69ce4d190b8072ca92a8f3bf04edf456e082b20c 100644 --- a/typo3/sysext/backend/Classes/Form/Wizard/ImageManipulationWizard.php +++ b/typo3/sysext/backend/Classes/Form/Wizard/ImageManipulationWizard.php @@ -17,6 +17,7 @@ namespace TYPO3\CMS\Backend\Form\Wizard; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException; use TYPO3\CMS\Core\Resource\ResourceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -51,10 +52,9 @@ class ImageManipulationWizard * Returns the HTML for the wizard inside the modal * * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface $response */ - public function getWizardAction(ServerRequestInterface $request, ResponseInterface $response) + public function getWizardAction(ServerRequestInterface $request): ResponseInterface { if ($this->isSignatureValid($request)) { $queryParams = json_decode($request->getQueryParams()['arguments'], true); @@ -71,11 +71,9 @@ class ImageManipulationWizard 'cropVariants' => $queryParams['cropVariants'] ]; $content = $this->templateView->renderSection('Main', $viewData); - $response->getBody()->write($content); - - return $response; + return new HtmlResponse($content); } - return $response->withStatus(403); + return new HtmlResponse('', 403); } /** diff --git a/typo3/sysext/backend/Tests/Unit/Controller/FormInlineAjaxControllerTest.php b/typo3/sysext/backend/Tests/Unit/Controller/FormInlineAjaxControllerTest.php index ead320561c5c6bd78b94146d9a43de9eb404ad40..ebfcf8250ac09a9bfffc95469f339f47595b8956 100644 --- a/typo3/sysext/backend/Tests/Unit/Controller/FormInlineAjaxControllerTest.php +++ b/typo3/sysext/backend/Tests/Unit/Controller/FormInlineAjaxControllerTest.php @@ -14,7 +14,6 @@ namespace TYPO3\CMS\Backend\Tests\Unit\Controller; * The TYPO3 project - inspiring people to share! */ -use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Backend\Controller\FormInlineAjaxController; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; @@ -34,7 +33,6 @@ class FormInlineAjaxControllerTest extends \TYPO3\TestingFramework\Core\Unit\Uni */ public function createActionThrowsExceptionIfContextIsEmpty() { - $responseProphecy = $this->prophesize(ResponseInterface::class); $requestProphecy = $this->prophesize(ServerRequestInterface::class); $requestProphecy->getParsedBody()->shouldBeCalled()->willReturn( [ @@ -45,7 +43,7 @@ class FormInlineAjaxControllerTest extends \TYPO3\TestingFramework\Core\Unit\Uni ); $this->expectException(\RuntimeException::class); $this->expectExceptionCode(1489751361); - (new FormInlineAjaxController())->createAction($requestProphecy->reveal(), $responseProphecy->reveal()); + (new FormInlineAjaxController())->createAction($requestProphecy->reveal()); } /** @@ -53,7 +51,6 @@ class FormInlineAjaxControllerTest extends \TYPO3\TestingFramework\Core\Unit\Uni */ public function createActionThrowsExceptionIfContextConfigSectionIsEmpty() { - $responseProphecy = $this->prophesize(ResponseInterface::class); $requestProphecy = $this->prophesize(ServerRequestInterface::class); $requestProphecy->getParsedBody()->shouldBeCalled()->willReturn( [ @@ -64,7 +61,7 @@ class FormInlineAjaxControllerTest extends \TYPO3\TestingFramework\Core\Unit\Uni ); $this->expectException(\RuntimeException::class); $this->expectExceptionCode(1489751362); - (new FormInlineAjaxController())->createAction($requestProphecy->reveal(), $responseProphecy->reveal()); + (new FormInlineAjaxController())->createAction($requestProphecy->reveal()); } /** @@ -72,7 +69,6 @@ class FormInlineAjaxControllerTest extends \TYPO3\TestingFramework\Core\Unit\Uni */ public function createActionThrowsExceptionIfContextConfigSectionDoesNotValidate() { - $responseProphecy = $this->prophesize(ResponseInterface::class); $requestProphecy = $this->prophesize(ServerRequestInterface::class); $requestProphecy->getParsedBody()->shouldBeCalled()->willReturn( [ @@ -90,7 +86,7 @@ class FormInlineAjaxControllerTest extends \TYPO3\TestingFramework\Core\Unit\Uni ); $this->expectException(\RuntimeException::class); $this->expectExceptionCode(1489751363); - (new FormInlineAjaxController())->createAction($requestProphecy->reveal(), $responseProphecy->reveal()); + (new FormInlineAjaxController())->createAction($requestProphecy->reveal()); } /** @@ -98,7 +94,6 @@ class FormInlineAjaxControllerTest extends \TYPO3\TestingFramework\Core\Unit\Uni */ public function detailsActionThrowsExceptionIfContextIsEmpty() { - $responseProphecy = $this->prophesize(ResponseInterface::class); $requestProphecy = $this->prophesize(ServerRequestInterface::class); $requestProphecy->getParsedBody()->shouldBeCalled()->willReturn( [ @@ -109,7 +104,7 @@ class FormInlineAjaxControllerTest extends \TYPO3\TestingFramework\Core\Unit\Uni ); $this->expectException(\RuntimeException::class); $this->expectExceptionCode(1489751361); - (new FormInlineAjaxController())->detailsAction($requestProphecy->reveal(), $responseProphecy->reveal()); + (new FormInlineAjaxController())->detailsAction($requestProphecy->reveal()); } /** @@ -117,7 +112,6 @@ class FormInlineAjaxControllerTest extends \TYPO3\TestingFramework\Core\Unit\Uni */ public function detailsActionThrowsExceptionIfContextConfigSectionIsEmpty() { - $responseProphecy = $this->prophesize(ResponseInterface::class); $requestProphecy = $this->prophesize(ServerRequestInterface::class); $requestProphecy->getParsedBody()->shouldBeCalled()->willReturn( [ @@ -128,7 +122,7 @@ class FormInlineAjaxControllerTest extends \TYPO3\TestingFramework\Core\Unit\Uni ); $this->expectException(\RuntimeException::class); $this->expectExceptionCode(1489751362); - (new FormInlineAjaxController())->detailsAction($requestProphecy->reveal(), $responseProphecy->reveal()); + (new FormInlineAjaxController())->detailsAction($requestProphecy->reveal()); } /** @@ -136,7 +130,6 @@ class FormInlineAjaxControllerTest extends \TYPO3\TestingFramework\Core\Unit\Uni */ public function detailsActionThrowsExceptionIfContextConfigSectionDoesNotValidate() { - $responseProphecy = $this->prophesize(ResponseInterface::class); $requestProphecy = $this->prophesize(ServerRequestInterface::class); $requestProphecy->getParsedBody()->shouldBeCalled()->willReturn( [ @@ -154,7 +147,7 @@ class FormInlineAjaxControllerTest extends \TYPO3\TestingFramework\Core\Unit\Uni ); $this->expectException(\RuntimeException::class); $this->expectExceptionCode(1489751363); - (new FormInlineAjaxController())->detailsAction($requestProphecy->reveal(), $responseProphecy->reveal()); + (new FormInlineAjaxController())->detailsAction($requestProphecy->reveal()); } /** @@ -162,7 +155,6 @@ class FormInlineAjaxControllerTest extends \TYPO3\TestingFramework\Core\Unit\Uni */ public function synchronizeLocalizeActionThrowsExceptionIfContextIsEmpty() { - $responseProphecy = $this->prophesize(ResponseInterface::class); $requestProphecy = $this->prophesize(ServerRequestInterface::class); $requestProphecy->getParsedBody()->shouldBeCalled()->willReturn( [ @@ -173,7 +165,7 @@ class FormInlineAjaxControllerTest extends \TYPO3\TestingFramework\Core\Unit\Uni ); $this->expectException(\RuntimeException::class); $this->expectExceptionCode(1489751361); - (new FormInlineAjaxController())->synchronizeLocalizeAction($requestProphecy->reveal(), $responseProphecy->reveal()); + (new FormInlineAjaxController())->synchronizeLocalizeAction($requestProphecy->reveal()); } /** @@ -181,7 +173,6 @@ class FormInlineAjaxControllerTest extends \TYPO3\TestingFramework\Core\Unit\Uni */ public function synchronizeLocalizeActionThrowsExceptionIfContextConfigSectionIsEmpty() { - $responseProphecy = $this->prophesize(ResponseInterface::class); $requestProphecy = $this->prophesize(ServerRequestInterface::class); $requestProphecy->getParsedBody()->shouldBeCalled()->willReturn( [ @@ -192,7 +183,7 @@ class FormInlineAjaxControllerTest extends \TYPO3\TestingFramework\Core\Unit\Uni ); $this->expectException(\RuntimeException::class); $this->expectExceptionCode(1489751362); - (new FormInlineAjaxController())->synchronizeLocalizeAction($requestProphecy->reveal(), $responseProphecy->reveal()); + (new FormInlineAjaxController())->synchronizeLocalizeAction($requestProphecy->reveal()); } /** @@ -200,7 +191,6 @@ class FormInlineAjaxControllerTest extends \TYPO3\TestingFramework\Core\Unit\Uni */ public function synchronizeLocalizeActionThrowsExceptionIfContextConfigSectionDoesNotValidate() { - $responseProphecy = $this->prophesize(ResponseInterface::class); $requestProphecy = $this->prophesize(ServerRequestInterface::class); $requestProphecy->getParsedBody()->shouldBeCalled()->willReturn( [ @@ -218,7 +208,7 @@ class FormInlineAjaxControllerTest extends \TYPO3\TestingFramework\Core\Unit\Uni ); $this->expectException(\RuntimeException::class); $this->expectExceptionCode(1489751363); - (new FormInlineAjaxController())->synchronizeLocalizeAction($requestProphecy->reveal(), $responseProphecy->reveal()); + (new FormInlineAjaxController())->synchronizeLocalizeAction($requestProphecy->reveal()); } /** diff --git a/typo3/sysext/backend/Tests/Unit/Controller/FormSelectTreeAjaxControllerTest.php b/typo3/sysext/backend/Tests/Unit/Controller/FormSelectTreeAjaxControllerTest.php index 9e2ebaf14bb1fe2ea8da79bd8e8f2eb1696f0fb8..78cdae5814e8b3a06900625e498c7a3fdd20a94e 100644 --- a/typo3/sysext/backend/Tests/Unit/Controller/FormSelectTreeAjaxControllerTest.php +++ b/typo3/sysext/backend/Tests/Unit/Controller/FormSelectTreeAjaxControllerTest.php @@ -14,7 +14,6 @@ namespace TYPO3\CMS\Backend\Tests\Unit\Controller; * The TYPO3 project - inspiring people to share! */ -use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Backend\Controller\FormSelectTreeAjaxController; @@ -29,10 +28,9 @@ class FormSelectTreeAjaxControllerTest extends \TYPO3\TestingFramework\Core\Unit public function fetchDataActionThrowsExceptionIfTcaOfTableDoesNotExist() { $requestProphecy = $this->prophesize(ServerRequestInterface::class); - $responseProphecy = $this->prophesize(ResponseInterface::class); $this->expectException(\RuntimeException::class); $this->expectExceptionCode(1479386729); - (new FormSelectTreeAjaxController())->fetchDataAction($requestProphecy->reveal(), $responseProphecy->reveal()); + (new FormSelectTreeAjaxController())->fetchDataAction($requestProphecy->reveal()); } /** @@ -40,7 +38,6 @@ class FormSelectTreeAjaxControllerTest extends \TYPO3\TestingFramework\Core\Unit */ public function fetchDataActionThrowsExceptionIfTcaOfTableFieldDoesNotExist() { - $responseProphecy = $this->prophesize(ResponseInterface::class); $requestProphecy = $this->prophesize(ServerRequestInterface::class); $requestProphecy->getQueryParams()->shouldBeCalled()->willReturn([ 'tableName' => 'aTable', @@ -49,6 +46,6 @@ class FormSelectTreeAjaxControllerTest extends \TYPO3\TestingFramework\Core\Unit $GLOBALS['TCA']['aTable']['columns'] = []; $this->expectException(\RuntimeException::class); $this->expectExceptionCode(1479386990); - (new FormSelectTreeAjaxController())->fetchDataAction($requestProphecy->reveal(), $responseProphecy->reveal()); + (new FormSelectTreeAjaxController())->fetchDataAction($requestProphecy->reveal()); } } diff --git a/typo3/sysext/backend/Tests/Unit/Controller/Wizard/SuggestWizardControllerTest.php b/typo3/sysext/backend/Tests/Unit/Controller/Wizard/SuggestWizardControllerTest.php index 2b724c62b38e6d580b54fc04fbcb21398e4f168e..fdd5f78082ba52b0c4181166bbad7e58e0661bfd 100644 --- a/typo3/sysext/backend/Tests/Unit/Controller/Wizard/SuggestWizardControllerTest.php +++ b/typo3/sysext/backend/Tests/Unit/Controller/Wizard/SuggestWizardControllerTest.php @@ -14,7 +14,6 @@ namespace TYPO3\CMS\Backend\Tests\Unit\Controller\Wizard; * The TYPO3 project - inspiring people to share! */ -use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Backend\Controller\Wizard\SuggestWizardController; use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools; @@ -35,7 +34,6 @@ class SuggestWizardControllerTest extends \TYPO3\TestingFramework\Core\Unit\Unit */ public function getFlexFieldConfigurationThrowsExceptionIfSimpleFlexFieldIsNotFound() { - $responseProphecy = $this->prophesize(ResponseInterface::class); $serverRequestProphecy = $this->prophesize(ServerRequestInterface::class); $serverRequestProphecy->getParsedBody()->willReturn([ 'value' => 'theSearchValue', @@ -73,7 +71,7 @@ class SuggestWizardControllerTest extends \TYPO3\TestingFramework\Core\Unit\Unit $this->expectException(\RuntimeException::class); $this->expectExceptionCode(1480609491); - (new SuggestWizardController())->searchAction($serverRequestProphecy->reveal(), $responseProphecy->reveal()); + (new SuggestWizardController())->searchAction($serverRequestProphecy->reveal()); } /** @@ -81,7 +79,6 @@ class SuggestWizardControllerTest extends \TYPO3\TestingFramework\Core\Unit\Unit */ public function getFlexFieldConfigurationThrowsExceptionIfSectionContainerFlexFieldIsNotFound() { - $responseProphecy = $this->prophesize(ResponseInterface::class); $serverRequestProphecy = $this->prophesize(ServerRequestInterface::class); $serverRequestProphecy->getParsedBody()->willReturn([ 'value' => 'theSearchValue', @@ -119,7 +116,7 @@ class SuggestWizardControllerTest extends \TYPO3\TestingFramework\Core\Unit\Unit $this->expectException(\RuntimeException::class); $this->expectExceptionCode(1480611208); - (new SuggestWizardController())->searchAction($serverRequestProphecy->reveal(), $responseProphecy->reveal()); + (new SuggestWizardController())->searchAction($serverRequestProphecy->reveal()); } /** diff --git a/typo3/sysext/beuser/Classes/Controller/PermissionAjaxController.php b/typo3/sysext/beuser/Classes/Controller/PermissionAjaxController.php index 23c2f355a5d31eebe6e6861bd44d6fbb6d1c9308..bc51e2e675c15fbc006c41c6ec71249f5c807464 100644 --- a/typo3/sysext/beuser/Classes/Controller/PermissionAjaxController.php +++ b/typo3/sysext/beuser/Classes/Controller/PermissionAjaxController.php @@ -18,6 +18,7 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\DataHandling\DataHandler; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; @@ -70,10 +71,9 @@ class PermissionAjaxController * The main dispatcher function. Collect data and prepare HTML output. * * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface */ - public function dispatch(ServerRequestInterface $request, ResponseInterface $response) + public function dispatch(ServerRequestInterface $request): ResponseInterface { $extPath = ExtensionManagementUtility::extPath('beuser'); @@ -81,13 +81,12 @@ class PermissionAjaxController $view->setPartialRootPaths(['default' => ExtensionManagementUtility::extPath('beuser') . 'Resources/Private/Partials']); $view->assign('pageId', $this->conf['page']); - $response = $response->withHeader('Content-Type', 'text/html; charset=utf-8'); + $response = new HtmlResponse(''); // Basic test for required value if ($this->conf['page'] <= 0) { $response->getBody()->write('This script cannot be called directly'); - $response = $response->withStatus(500); - return $response; + return $response->withStatus(500); } $content = ''; diff --git a/typo3/sysext/core/Classes/Controller/FileDumpController.php b/typo3/sysext/core/Classes/Controller/FileDumpController.php index 5f1cd07308ccd4b116f3997b9f58cd9112f0b813..f80f97c480f329d21ca9cfc8fe98d9589089e64e 100644 --- a/typo3/sysext/core/Classes/Controller/FileDumpController.php +++ b/typo3/sysext/core/Classes/Controller/FileDumpController.php @@ -16,6 +16,7 @@ namespace TYPO3\CMS\Core\Controller; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Resource\Hook\FileDumpEIDHookInterface; use TYPO3\CMS\Core\Resource\ProcessedFileRepository; use TYPO3\CMS\Core\Resource\ResourceFactory; @@ -31,7 +32,6 @@ class FileDumpController * Main method to dump a file * * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface|null * * @throws \InvalidArgumentException @@ -39,7 +39,7 @@ class FileDumpController * @throws \TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException * @throws \UnexpectedValueException */ - public function dumpAction(ServerRequestInterface $request, ResponseInterface $response) + public function dumpAction(ServerRequestInterface $request) { $parameters = ['eID' => 'dumpFile']; $t = $this->getGetOrPost($request, 't'); @@ -88,7 +88,7 @@ class FileDumpController // @todo Refactor FAL to not echo directly, but to implement a stream for output here and use response return null; } - return $response->withStatus(403); + return new HtmlResponse('', 403); } /** diff --git a/typo3/sysext/core/Classes/Imaging/IconFactory.php b/typo3/sysext/core/Classes/Imaging/IconFactory.php index 8a9794d8e782f41b32a7eb514289bb48da0ea633..f2fe258a40109fbd38827aa66450854fcbf47b21 100644 --- a/typo3/sysext/core/Classes/Imaging/IconFactory.php +++ b/typo3/sysext/core/Classes/Imaging/IconFactory.php @@ -16,6 +16,7 @@ namespace TYPO3\CMS\Core\Imaging; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Resource\File; use TYPO3\CMS\Core\Resource\FolderInterface; use TYPO3\CMS\Core\Resource\InaccessibleFolder; @@ -71,11 +72,10 @@ class IconFactory /** * @param ServerRequestInterface $request - * @param ResponseInterface $response - * @return string + * @return ResponseInterface * @internal */ - public function processAjaxRequest(ServerRequestInterface $request, ResponseInterface $response) + public function processAjaxRequest(ServerRequestInterface $request): ResponseInterface { $parsedBody = $request->getParsedBody(); $queryParams = $request->getQueryParams(); @@ -89,11 +89,7 @@ class IconFactory $overlayIdentifier = null; } $iconState = IconState::cast($iconState); - $response->getBody()->write( - $this->getIcon($identifier, $size, $overlayIdentifier, $iconState)->render($alternativeMarkupIdentifier) - ); - $response = $response->withHeader('Content-Type', 'text/html; charset=utf-8'); - return $response; + return new HtmlResponse($this->getIcon($identifier, $size, $overlayIdentifier, $iconState)->render($alternativeMarkupIdentifier)); } /** diff --git a/typo3/sysext/documentation/Classes/Controller/DocumentController.php b/typo3/sysext/documentation/Classes/Controller/DocumentController.php index adb02c926f906bf3faf8c202d932844c6f9e11aa..6ca16b9fa70c1add00593f9b56dc1e7b22e83ab6 100644 --- a/typo3/sysext/documentation/Classes/Controller/DocumentController.php +++ b/typo3/sysext/documentation/Classes/Controller/DocumentController.php @@ -181,7 +181,7 @@ class DocumentController extends ActionController * @param ServerRequestInterface $request * @return ResponseInterface */ - public function deleteAction(ServerRequestInterface $request) + public function deleteAction(ServerRequestInterface $request): ResponseInterface { $basePath = 'typo3conf/Documentation/'; $packageKey = $request->getParsedBody(); @@ -189,8 +189,7 @@ class DocumentController extends ActionController if (!$isDirDeleted) { $this->addFlashMessage(LocalizationUtility::translate('deleteFailed', 'Documentation'), '', FlashMessage::ERROR); } - - return GeneralUtility::makeInstance(JsonResponse::class)->setPayload([$isDirDeleted]); + return new JsonResponse([$isDirDeleted]); } /** diff --git a/typo3/sysext/frontend/Classes/Controller/ShowImageController.php b/typo3/sysext/frontend/Classes/Controller/ShowImageController.php index d1f8a63f0901c15757ccaaf5d838bf96e9d49fa4..370988af5025359e9e426f4258464f84a009388e 100644 --- a/typo3/sysext/frontend/Classes/Controller/ShowImageController.php +++ b/typo3/sysext/frontend/Classes/Controller/ShowImageController.php @@ -17,6 +17,7 @@ namespace TYPO3\CMS\Frontend\Controller; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Core\Exception; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Resource\ProcessedFile; use TYPO3\CMS\Core\Resource\ResourceFactory; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -190,23 +191,21 @@ EOF; * Fetches the content and builds a content file out of it * * @param ServerRequestInterface $request the current request object - * @param ResponseInterface $response the available response * @return ResponseInterface the modified response */ - public function processRequest(ServerRequestInterface $request, ResponseInterface $response) + public function processRequest(ServerRequestInterface $request): ResponseInterface { $this->request = $request; try { $this->initialize(); $this->main(); - $response->getBody()->write($this->content); - return $response; + return new HtmlResponse($this->content); } catch (\InvalidArgumentException $e) { // add a 410 "gone" if invalid parameters given - return $response->withStatus(410); + return new HtmlResponse('', 410); } catch (Exception $e) { - return $response->withStatus(404); + return new HtmlResponse('', 404); } } } diff --git a/typo3/sysext/impexp/Classes/Controller/ImportExportController.php b/typo3/sysext/impexp/Classes/Controller/ImportExportController.php index 2a7b987603343212dc58ba3e42eae0cbcdcb072f..de8c2d27602f9554b73313ba040a016dd9f33c9a 100644 --- a/typo3/sysext/impexp/Classes/Controller/ImportExportController.php +++ b/typo3/sysext/impexp/Classes/Controller/ImportExportController.php @@ -25,6 +25,7 @@ use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\QueryHelper; 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\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Localization\LanguageService; @@ -292,18 +293,15 @@ class ImportExportController extends BaseScriptClass * external_ref[tables][]=table/_ALL * * @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 { $GLOBALS['SOBE'] = $this; $this->init(); $this->main(); $this->moduleTemplate->setContent($this->standaloneView->render()); - $response->getBody()->write($this->moduleTemplate->renderContent()); - - return $response; + return new HtmlResponse($this->moduleTemplate->renderContent()); } /** diff --git a/typo3/sysext/info/Classes/Controller/InfoModuleController.php b/typo3/sysext/info/Classes/Controller/InfoModuleController.php index 77a740bafa5dcd7108354929f7e2bcfd6ef81c49..9a7b480b6af59d0e4ff4d8c23d1ea789ea19ea85 100644 --- a/typo3/sysext/info/Classes/Controller/InfoModuleController.php +++ b/typo3/sysext/info/Classes/Controller/InfoModuleController.php @@ -20,6 +20,7 @@ use TYPO3\CMS\Backend\Module\BaseScriptClass; use TYPO3\CMS\Backend\Template\Components\ButtonBar; use TYPO3\CMS\Backend\Template\ModuleTemplate; use TYPO3\CMS\Backend\Utility\BackendUtility; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Fluid\View\StandaloneView; @@ -132,10 +133,9 @@ class InfoModuleController extends BaseScriptClass * Then checks for module functions that have hooked in, and renders menu etc. * * @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 { $GLOBALS['SOBE'] = $this; $this->init(); @@ -148,8 +148,7 @@ class InfoModuleController extends BaseScriptClass $this->main(); $this->moduleTemplate->setContent($this->content); - $response->getBody()->write($this->moduleTemplate->renderContent()); - return $response; + return new HtmlResponse($this->moduleTemplate->renderContent()); } /** diff --git a/typo3/sysext/install/Classes/Controller/BackendModuleController.php b/typo3/sysext/install/Classes/Controller/BackendModuleController.php index 13e7c0f64e6a7e496199753b3d7c1d543d38634b..64fdd86716a54d69efa1544cc35a537653b5857b 100644 --- a/typo3/sysext/install/Classes/Controller/BackendModuleController.php +++ b/typo3/sysext/install/Classes/Controller/BackendModuleController.php @@ -16,7 +16,6 @@ namespace TYPO3\CMS\Install\Controller; */ use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Core\Http\RedirectResponse; use TYPO3\CMS\Install\Service\SessionService; @@ -34,11 +33,9 @@ class BackendModuleController /** * Initialize session and redirect to "maintenance" * - * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface */ - public function maintenanceAction(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface + public function maintenanceAction(): ResponseInterface { return $this->setAuthorizedAndRedirect('maintenance'); } @@ -46,11 +43,9 @@ class BackendModuleController /** * Initialize session and redirect to "settings" * - * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface */ - public function settingsAction(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface + public function settingsAction(): ResponseInterface { return $this->setAuthorizedAndRedirect('settings'); } @@ -58,11 +53,9 @@ class BackendModuleController /** * Initialize session and redirect to "upgrade" * - * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface */ - public function upgradeAction(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface + public function upgradeAction(): ResponseInterface { return $this->setAuthorizedAndRedirect('upgrade'); } @@ -70,11 +63,9 @@ class BackendModuleController /** * Initialize session and redirect to "environment" * - * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface */ - public function environmentAction(ServerRequestInterface $request, ResponseInterface $response): ResponseInterface + public function environmentAction(): ResponseInterface { return $this->setAuthorizedAndRedirect('environment'); } diff --git a/typo3/sysext/lowlevel/Classes/Controller/ConfigurationController.php b/typo3/sysext/lowlevel/Classes/Controller/ConfigurationController.php index 90295e8172d9992e69ea3a2b2f459dd899822101..6518b8d49600fb5c9f5428e00319d0b90d83fc3c 100644 --- a/typo3/sysext/lowlevel/Classes/Controller/ConfigurationController.php +++ b/typo3/sysext/lowlevel/Classes/Controller/ConfigurationController.php @@ -22,6 +22,7 @@ use TYPO3\CMS\Backend\Template\ModuleTemplate; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Cache\Backend\NullBackend; use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Http\MiddlewareStackResolver; use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Package\PackageManager; @@ -147,11 +148,10 @@ class ConfigurationController * and renders it. * * @param ServerRequestInterface $request the current request - * @param ResponseInterface $response * @return ResponseInterface the response with the content * @throws \RuntimeException */ - public function mainAction(ServerRequestInterface $request, ResponseInterface $response) + public function mainAction(ServerRequestInterface $request): ResponseInterface { $backendUser = $this->getBackendUser(); $languageService = $this->getLanguageService(); @@ -304,8 +304,7 @@ class ConfigurationController } $moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu); - $response->getBody()->write($moduleTemplate->renderContent()); - return $response; + return new HtmlResponse($moduleTemplate->renderContent()); } /** diff --git a/typo3/sysext/lowlevel/Classes/Controller/DatabaseIntegrityController.php b/typo3/sysext/lowlevel/Classes/Controller/DatabaseIntegrityController.php index 33b778fb54116544ac87b5999439aefbbacf0abc..59b1eef5dbb96625ad2240a48d4d47da23389063 100644 --- a/typo3/sysext/lowlevel/Classes/Controller/DatabaseIntegrityController.php +++ b/typo3/sysext/lowlevel/Classes/Controller/DatabaseIntegrityController.php @@ -21,6 +21,7 @@ use TYPO3\CMS\Backend\Template\ModuleTemplate; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Database\QueryView; use TYPO3\CMS\Core\Database\ReferenceIndex; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck; @@ -103,10 +104,9 @@ class DatabaseIntegrityController * Simply calls main() and init() and outputs the content * * @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->getLanguageService()->includeLLFile('EXT:lowlevel/Resources/Private/Language/locallang.xlf'); $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class); @@ -163,8 +163,7 @@ class DatabaseIntegrityController $this->getModuleMenu(); $this->moduleTemplate->setContent($content); - $response->getBody()->write($this->moduleTemplate->renderContent()); - return $response; + return new HtmlResponse($this->moduleTemplate->renderContent()); } /** diff --git a/typo3/sysext/opendocs/Classes/Backend/ToolbarItems/OpendocsToolbarItem.php b/typo3/sysext/opendocs/Classes/Backend/ToolbarItems/OpendocsToolbarItem.php index 6fadd03a7ede3d1fac777afb83c226bdd551e2fe..55257aa666fc34c34944df7ffc6d453c68c07a43 100644 --- a/typo3/sysext/opendocs/Classes/Backend/ToolbarItems/OpendocsToolbarItem.php +++ b/typo3/sysext/opendocs/Classes/Backend/ToolbarItems/OpendocsToolbarItem.php @@ -19,6 +19,7 @@ use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Fluid\View\StandaloneView; @@ -196,10 +197,9 @@ class OpendocsToolbarItem implements ToolbarItemInterface * Closes a document in the session and * * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface */ - public function closeDocument(ServerRequestInterface $request, ResponseInterface $response) + public function closeDocument(ServerRequestInterface $request): ResponseInterface { $md5sum = $request->getParsedBody()['md5sum'] ?? $request->getQueryParams()['md5sum']; if ($md5sum && isset($this->openDocs[$md5sum])) { @@ -216,20 +216,17 @@ class OpendocsToolbarItem implements ToolbarItemInterface $backendUser->pushModuleData('FormEngine', [$this->openDocs, $docDat]); $backendUser->pushModuleData('opendocs::recent', $this->recentDocs); } - return $this->renderMenu($request, $response); + return $this->renderMenu(); } /** * 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 renderMenu(ServerRequestInterface $request, ResponseInterface $response) + public function renderMenu(): ResponseInterface { - $response->getBody()->write($this->getDropDown()); - return $response->withHeader('Content-Type', 'text/html; charset=utf-8'); + return new HtmlResponse($this->getDropDown()); } /** diff --git a/typo3/sysext/recordlist/Classes/Controller/AbstractLinkBrowserController.php b/typo3/sysext/recordlist/Classes/Controller/AbstractLinkBrowserController.php index 5caa794ea3020e3e8518a0823b5b63614dbacc63..57cf96206b81ae278a9c67e74cbc827051128c0b 100644 --- a/typo3/sysext/recordlist/Classes/Controller/AbstractLinkBrowserController.php +++ b/typo3/sysext/recordlist/Classes/Controller/AbstractLinkBrowserController.php @@ -20,6 +20,7 @@ use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\Template\DocumentTemplate; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Service\DependencyOrderingService; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -147,10 +148,9 @@ abstract class AbstractLinkBrowserController * As this controller goes only through the main() method, it is rather simple for now * * @param ServerRequestInterface $request the current request - * @param ResponseInterface $response the prepared response object * @return ResponseInterface the response with the content */ - public function mainAction(ServerRequestInterface $request, ResponseInterface $response) + public function mainAction(ServerRequestInterface $request): ResponseInterface { $this->determineScriptUrl($request); $this->initVariables($request); @@ -186,8 +186,7 @@ abstract class AbstractLinkBrowserController $content .= $browserContent; $content .= $this->doc->endPage(); - $response->getBody()->write($this->doc->insertStylesAndJS($content)); - return $response; + return new HtmlResponse($this->doc->insertStylesAndJS($content)); } /** diff --git a/typo3/sysext/recordlist/Classes/Controller/ElementBrowserController.php b/typo3/sysext/recordlist/Classes/Controller/ElementBrowserController.php index b0c563c7de5579bddbb259ff7bd82f37da4db49a..9f02502f2d3bb44f1ded404d3005f2a8458f183a 100644 --- a/typo3/sysext/recordlist/Classes/Controller/ElementBrowserController.php +++ b/typo3/sysext/recordlist/Classes/Controller/ElementBrowserController.php @@ -16,8 +16,11 @@ namespace TYPO3\CMS\Recordlist\Controller; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\Template\DocumentTemplate; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; +use TYPO3\CMS\Core\Http\HtmlResponse; +use TYPO3\CMS\Core\Http\RedirectResponse; use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Recordlist\Browser\ElementBrowserInterface; @@ -76,20 +79,16 @@ class ElementBrowserController * As this controller goes only through the main() method, it is rather simple for now * * @param ServerRequestInterface $request the current request - * @param ResponseInterface $response the prepared response object * @return ResponseInterface the response with the content */ - public function mainAction(ServerRequestInterface $request, ResponseInterface $response) + public function mainAction(ServerRequestInterface $request): ResponseInterface { // Fallback for old calls, which use mode "wizard" or "rte" for link selection if ($this->mode === 'wizard' || $this->mode === 'rte') { - /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */ - $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class); - return $response->withStatus(303)->withHeader('Location', (string)$uriBuilder->buildUriFromRoute('wizard_link', $_GET)); + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); + return new RedirectResponse((string)$uriBuilder->buildUriFromRoute('wizard_link', $_GET), 303); } - - $response->getBody()->write($this->main()); - return $response; + return new HtmlResponse($this->main()); } /** diff --git a/typo3/sysext/recordlist/Classes/Controller/ElementBrowserFramesetController.php b/typo3/sysext/recordlist/Classes/Controller/ElementBrowserFramesetController.php index bc11b7b024f54536a743eb2ea33185089ba95704..fe6c0f65464bcdafdee46a70b708715ea1998984 100644 --- a/typo3/sysext/recordlist/Classes/Controller/ElementBrowserFramesetController.php +++ b/typo3/sysext/recordlist/Classes/Controller/ElementBrowserFramesetController.php @@ -17,6 +17,7 @@ namespace TYPO3\CMS\Recordlist\Controller; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Backend\Template\DocumentTemplate; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -51,15 +52,12 @@ class ElementBrowserFramesetController * As this controller goes only through the main() method, it is rather simple for now * * @param ServerRequestInterface $request the current request - * @param ResponseInterface $response the prepared 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->content); - return $response; + return new HtmlResponse($this->content); } /** diff --git a/typo3/sysext/recordlist/Classes/RecordList.php b/typo3/sysext/recordlist/Classes/RecordList.php index 2dcc33d56fb13be61b6533f5e45bdadd9616658f..a15533e4005014c8fac8608c3aab7e22a2a103b5 100644 --- a/typo3/sysext/recordlist/Classes/RecordList.php +++ b/typo3/sysext/recordlist/Classes/RecordList.php @@ -25,6 +25,7 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction; use TYPO3\CMS\Core\DataHandling\DataHandler; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Localization\LanguageService; @@ -586,10 +587,9 @@ class RecordList * Simply calls main() and init() and outputs the content * * @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 { BackendUtility::lockRecords(); $GLOBALS['SOBE'] = $this; @@ -597,8 +597,7 @@ class RecordList $this->clearCache(); $this->main(); $this->moduleTemplate->setContent($this->content); - $response->getBody()->write($this->moduleTemplate->renderContent()); - return $response; + return new HtmlResponse($this->moduleTemplate->renderContent()); } /** diff --git a/typo3/sysext/recycler/Classes/Controller/RecyclerAjaxController.php b/typo3/sysext/recycler/Classes/Controller/RecyclerAjaxController.php index e7237d4755ad24d682d679a0ee5e6c6d56035e1c..7a2759c1593c98c946dec2afb5707a64180414b1 100644 --- a/typo3/sysext/recycler/Classes/Controller/RecyclerAjaxController.php +++ b/typo3/sysext/recycler/Classes/Controller/RecyclerAjaxController.php @@ -64,7 +64,7 @@ class RecyclerAjaxController * @param ServerRequestInterface $request * @return ResponseInterface */ - public function dispatch(ServerRequestInterface $request) + public function dispatch(ServerRequestInterface $request): ResponseInterface { $extPath = ExtensionManagementUtility::extPath('recycler'); /* @var $view StandaloneView */ @@ -150,7 +150,7 @@ class RecyclerAjaxController ]; break; } - return GeneralUtility::makeInstance(JsonResponse::class)->setPayload($content); + return (new JsonResponse())->setPayload($content); } /** diff --git a/typo3/sysext/rsaauth/Classes/Controller/RsaPublicKeyGenerationController.php b/typo3/sysext/rsaauth/Classes/Controller/RsaPublicKeyGenerationController.php index 30659bc5ff0e45635f3ed2bacdf15ffe38e693f1..2fa83acac94b2586b3215578aecde37b5757f2ad 100644 --- a/typo3/sysext/rsaauth/Classes/Controller/RsaPublicKeyGenerationController.php +++ b/typo3/sysext/rsaauth/Classes/Controller/RsaPublicKeyGenerationController.php @@ -16,6 +16,7 @@ namespace TYPO3\CMS\Rsaauth\Controller; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Rsaauth\Backend\BackendFactory; use TYPO3\CMS\Rsaauth\Storage\StorageFactory; @@ -26,16 +27,15 @@ class RsaPublicKeyGenerationController { /** * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface */ - public function processRequest(ServerRequestInterface $request, ResponseInterface $response) + public function processRequest(ServerRequestInterface $request): ResponseInterface { /** @var \TYPO3\CMS\Rsaauth\Backend\AbstractBackend $backend */ $backend = BackendFactory::getBackend(); if ($backend === null) { // add a HTTP 500 error code, if an error occurred - return $response->withStatus(500); + return new HtmlResponse('', 500); } $keyPair = $backend->createNewKeyPair(); @@ -43,7 +43,6 @@ class RsaPublicKeyGenerationController $storage->put($keyPair->getPrivateKey()); session_commit(); $content = $keyPair->getPublicKeyModulus() . ':' . sprintf('%x', $keyPair->getExponent()) . ':'; - $response->getBody()->write($content); - return $response; + return new HtmlResponse($content); } } diff --git a/typo3/sysext/rsaauth/Classes/RsaEncryptionEncoder.php b/typo3/sysext/rsaauth/Classes/RsaEncryptionEncoder.php index fd31ea03d5520e63a0791f85c4a094a25bd16352..5bb6dda074044bdf7e9e89b31cff8d09af66e52c 100644 --- a/typo3/sysext/rsaauth/Classes/RsaEncryptionEncoder.php +++ b/typo3/sysext/rsaauth/Classes/RsaEncryptionEncoder.php @@ -15,7 +15,7 @@ namespace TYPO3\CMS\Rsaauth; */ use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\SingletonInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -106,24 +106,20 @@ class RsaEncryptionEncoder implements SingletonInterface /** * Ajax handler to return a RSA public key. * - * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface */ - public function getRsaPublicKeyAjaxHandler(ServerRequestInterface $request, ResponseInterface $response) + public function getRsaPublicKeyAjaxHandler(): ResponseInterface { $keyPair = $this->getRsaPublicKey(); if ($keyPair !== null) { - $response->getBody()->write(implode('', [ - 'publicKeyModulus' => $keyPair->getPublicKeyModulus(), - 'spacer' => ':', - 'exponent' => sprintf('%x', $keyPair->getExponent()) - ])); - $response = $response->withHeader('Content-Type', 'text/html; charset=utf-8'); - } else { - $response->getBody()->write('No OpenSSL backend could be obtained for rsaauth.'); - $response = $response->withStatus(500); + return new HtmlResponse( + implode('', [ + 'publicKeyModulus' => $keyPair->getPublicKeyModulus(), + 'spacer' => ':', + 'exponent' => sprintf('%x', $keyPair->getExponent()) + ]) + ); } - return $response; + return new HtmlResponse('No OpenSSL backend could be obtained for rsaauth.', 500); } } diff --git a/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php b/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php index cf7663911dfbe19584b893a156c3ad105f523375..c602b12ad045c75cb051be3da6ba9138e2d05fc8 100644 --- a/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php +++ b/typo3/sysext/scheduler/Classes/Controller/SchedulerModuleController.php @@ -20,6 +20,7 @@ use TYPO3\CMS\Backend\Template\Components\ButtonBar; 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\Localization\LanguageService; @@ -146,10 +147,9 @@ class SchedulerModuleController * Simply calls main() and init() and outputs the content * * @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->CMD = GeneralUtility::_GP('CMD'); $this->MOD_MENU = [ @@ -179,8 +179,7 @@ class SchedulerModuleController $this->getModuleMenu(); $this->moduleTemplate->setContent($content); - $response->getBody()->write($this->moduleTemplate->renderContent()); - return $response; + return new HtmlResponse($this->moduleTemplate->renderContent()); } /** diff --git a/typo3/sysext/setup/Classes/Controller/SetupModuleController.php b/typo3/sysext/setup/Classes/Controller/SetupModuleController.php index 8d70c150e0cebaad721a075448b23af9b0166556..8a2155641db4d04472fdfa657c36c6749404ec5b 100644 --- a/typo3/sysext/setup/Classes/Controller/SetupModuleController.php +++ b/typo3/sysext/setup/Classes/Controller/SetupModuleController.php @@ -24,6 +24,7 @@ use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\DataHandling\DataHandler; use TYPO3\CMS\Core\FormProtection\FormProtectionFactory; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Messaging\FlashMessage; @@ -426,19 +427,16 @@ class SetupModuleController * Simply calls main() and init() and writes the content to the response * * @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 { $GLOBALS['SOBE'] = $this; $this->simulateUser(); $this->init(); $this->storeIncomingData(); $this->main(); - - $response->getBody()->write($this->moduleTemplate->renderContent()); - return $response; + return new HtmlResponse($this->moduleTemplate->renderContent()); } /** diff --git a/typo3/sysext/t3editor/Classes/CodeCompletion.php b/typo3/sysext/t3editor/Classes/CodeCompletion.php index d234e82d00bd390597714d6940e0c4c689a433f0..5770cb21df2467d0ed03d2fb79300c1a636118c7 100644 --- a/typo3/sysext/t3editor/Classes/CodeCompletion.php +++ b/typo3/sysext/t3editor/Classes/CodeCompletion.php @@ -15,9 +15,8 @@ namespace TYPO3\CMS\T3editor; */ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Http\JsonResponse; -use TYPO3\CMS\Core\Http\Response; -use TYPO3\CMS\Core\Utility\GeneralUtility; /** * Code completion for t3editor @@ -42,10 +41,9 @@ class CodeCompletion * Called by AjaxRequestHandler * * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface */ - public function processAjaxRequest(ServerRequestInterface $request, ResponseInterface $response) + public function processAjaxRequest(ServerRequestInterface $request): ResponseInterface { $pageId = (int)($request->getParsedBody()['pageId'] ?? $request->getQueryParams()['pageId']); return $this->loadTemplates($pageId); @@ -60,22 +58,15 @@ class CodeCompletion */ protected function loadTemplates($pageId): ResponseInterface { - $response = GeneralUtility::makeInstance(Response::class); - // Check whether access is granted (only admin have access to sys_template records): if ($GLOBALS['BE_USER']->isAdmin()) { // Check whether there is a pageId given: if ($pageId) { - $response = GeneralUtility::makeInstance(JsonResponse::class)->setPayload($this->getMergedTemplates($pageId)); - } else { - $response->getBody()->write($GLOBALS['LANG']->getLL('pageIDInteger')); - $response = $response->withStatus(500); + return (new JsonResponse())->setPayload($this->getMergedTemplates($pageId)); } - } else { - $response->getBody()->write($GLOBALS['LANG']->getLL('noPermission')); - $response = $response->withStatus(500); + return new HtmlResponse($GLOBALS['LANG']->getLL('pageIDInteger'), 500); } - return $response; + return new HtmlResponse($GLOBALS['LANG']->getLL('noPermission'), 500); } /** @@ -83,10 +74,9 @@ class CodeCompletion * * @todo oliver@typo3.org: Refactor this method and comment what's going on there * @param int $pageId - * @param int $templateId * @return array Setup part of merged template records */ - protected function getMergedTemplates($pageId, $templateId = 0) + protected function getMergedTemplates($pageId) { /** @var $tsParser \TYPO3\CMS\Core\TypoScript\ExtendedTemplateService */ $tsParser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\TypoScript\ExtendedTemplateService::class); diff --git a/typo3/sysext/t3editor/Classes/TypoScriptReferenceLoader.php b/typo3/sysext/t3editor/Classes/TypoScriptReferenceLoader.php index 7a58c7375b0f1b5e2eead38bf54c79381c67e6c8..ceec7d6df33774329563cc618319b9f8d8a01ed6 100644 --- a/typo3/sysext/t3editor/Classes/TypoScriptReferenceLoader.php +++ b/typo3/sysext/t3editor/Classes/TypoScriptReferenceLoader.php @@ -47,7 +47,7 @@ class TypoScriptReferenceLoader { // Load the TSref XML information: $this->loadFile(GeneralUtility::getFileAbsFileName('EXT:t3editor/Resources/Private/tsref.xml')); - return GeneralUtility::makeInstance(JsonResponse::class)->setPayload($this->getTypes()); + return (new JsonResponse())->setPayload($this->getTypes()); } /** diff --git a/typo3/sysext/taskcenter/Classes/Controller/TaskModuleController.php b/typo3/sysext/taskcenter/Classes/Controller/TaskModuleController.php index d3d65f9a6f7bc8cc873130cd584146629a4b2e6f..648f7871deaef20b11ed373fe0704d19f25860fd 100644 --- a/typo3/sysext/taskcenter/Classes/Controller/TaskModuleController.php +++ b/typo3/sysext/taskcenter/Classes/Controller/TaskModuleController.php @@ -19,6 +19,7 @@ use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Backend\Module\BaseScriptClass; use TYPO3\CMS\Backend\Template\ModuleTemplate; use TYPO3\CMS\Backend\Utility\BackendUtility; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\PathUtility; @@ -120,18 +121,15 @@ class TaskModuleController extends BaseScriptClass * Simply calls main() and writes the content to the response * * @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 { $GLOBALS['SOBE'] = $this; $this->main(); $this->moduleTemplate->setContent($this->content); - - $response->getBody()->write($this->moduleTemplate->renderContent()); - return $response; + return new HtmlResponse($this->moduleTemplate->renderContent()); } /** diff --git a/typo3/sysext/taskcenter/Classes/TaskStatus.php b/typo3/sysext/taskcenter/Classes/TaskStatus.php index 59322eb38971aefaa224d2fc3bde4ae729c39cbc..20aa6878f909b35535451c8d4b14afc36413a0a2 100644 --- a/typo3/sysext/taskcenter/Classes/TaskStatus.php +++ b/typo3/sysext/taskcenter/Classes/TaskStatus.php @@ -16,6 +16,7 @@ namespace TYPO3\CMS\Taskcenter; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; +use TYPO3\CMS\Core\Http\HtmlResponse; /** * Status of tasks @@ -26,10 +27,9 @@ class TaskStatus * Saves the section toggle state of tasks in the backend user's uc * * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface */ - public function saveCollapseState(ServerRequestInterface $request, ResponseInterface $response) + public function saveCollapseState(ServerRequestInterface $request): ResponseInterface { // Remove 'el_' in the beginning which is needed for the saveSortingState() $item = $request->getParsedBody()['item'] ?? $request->getQueryParams()['item']; @@ -39,17 +39,16 @@ class TaskStatus $this->getBackendUserAuthentication()->uc['taskcenter']['states'][$item] = $state; $this->getBackendUserAuthentication()->writeUC(); - return $response; + return new HtmlResponse(''); } /** * Saves the sorting order of tasks in the backend user's uc * * @param ServerRequestInterface $request - * @param ResponseInterface $response * @return ResponseInterface */ - public function saveSortingState(ServerRequestInterface $request, ResponseInterface $response) + public function saveSortingState(ServerRequestInterface $request): ResponseInterface { $sort = []; $data = $request->getParsedBody()['data'] ?? $request->getQueryParams()['data']; @@ -61,7 +60,7 @@ class TaskStatus $this->getBackendUserAuthentication()->uc['taskcenter']['sorting'] = serialize($sort); $this->getBackendUserAuthentication()->writeUC(); - return $response; + return new HtmlResponse(''); } /** diff --git a/typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateModuleController.php b/typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateModuleController.php index 16781efa1d09c074196db3f37dea00c6a1fe6bec..3795a33285ff5b4dec4fdd0a512b2c8186a4d9d1 100644 --- a/typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateModuleController.php +++ b/typo3/sysext/tstemplate/Classes/Controller/TypoScriptTemplateModuleController.php @@ -24,6 +24,7 @@ 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\DataHandling\DataHandler; +use TYPO3\CMS\Core\Http\HtmlResponse; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Type\Bitmask\Permission; use TYPO3\CMS\Core\TypoScript\ExtendedTemplateService; @@ -275,10 +276,9 @@ class TypoScriptTemplateModuleController extends BaseScriptClass * Then checks for module functions that have hooked in, and renders menu etc. * * @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 { $GLOBALS['SOBE'] = $this; $this->init(); @@ -290,8 +290,7 @@ class TypoScriptTemplateModuleController extends BaseScriptClass $this->main(); $this->moduleTemplate->setContent($this->content); - $response->getBody()->write($this->moduleTemplate->renderContent()); - return $response; + return new HtmlResponse($this->moduleTemplate->renderContent()); } /** diff --git a/typo3/sysext/workspaces/Classes/Controller/AjaxController.php b/typo3/sysext/workspaces/Classes/Controller/AjaxController.php index 4d87a5e2901902acba5b35292fe8ee3fe79bcead..014ea515572f39e0acc5931e6d3e035827a2e333 100644 --- a/typo3/sysext/workspaces/Classes/Controller/AjaxController.php +++ b/typo3/sysext/workspaces/Classes/Controller/AjaxController.php @@ -18,7 +18,6 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Http\JsonResponse; -use TYPO3\CMS\Core\Utility\GeneralUtility; /** * Implements the AJAX functionality for the various asynchronous calls @@ -69,7 +68,7 @@ class AjaxController 'workspaceId' => $workspaceId, 'pageId' => ($finalPageUid && $originalPageId == $finalPageUid) ? null : $finalPageUid ]; - return GeneralUtility::makeInstance(JsonResponse::class, $ajaxResponse); + return new JsonResponse($ajaxResponse); } /** diff --git a/typo3/sysext/workspaces/Classes/Controller/AjaxDispatcher.php b/typo3/sysext/workspaces/Classes/Controller/AjaxDispatcher.php index 713e5ae1583d688d4b604b5d53f39203f4db2916..c07e8750b19de3e7dfe4e1fb31a76ce00a99f949 100644 --- a/typo3/sysext/workspaces/Classes/Controller/AjaxDispatcher.php +++ b/typo3/sysext/workspaces/Classes/Controller/AjaxDispatcher.php @@ -54,7 +54,7 @@ class AjaxDispatcher $instance = GeneralUtility::makeInstance($className); $results[] = $this->buildResultFromResponse(call_user_func_array([$instance, $method], $parameters), $call); } - return GeneralUtility::makeInstance(JsonResponse::class)->setPayload($results); + return (new JsonResponse())->setPayload($results); } /**