From 19aa3b44b2ee4b6277d9424c726c8d9199e6f020 Mon Sep 17 00:00:00 2001 From: Mathias Brodala <mbrodala@pagemachine.de> Date: Sat, 17 Mar 2018 09:17:41 +0100 Subject: [PATCH] [TASK] Drop remaining getIndpEnv() in NewRecordController Change-Id: Ic5382b1705be90cb7b7ae66d4832c1fb0ba44da8 Resolves: #84391 Related: #84341 Releases: master Reviewed-on: https://review.typo3.org/56266 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> --- .../Controller/NewRecordController.php | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/typo3/sysext/backend/Classes/Controller/NewRecordController.php b/typo3/sysext/backend/Classes/Controller/NewRecordController.php index 3e5b186ed8a9..c203d501ac93 100644 --- a/typo3/sysext/backend/Classes/Controller/NewRecordController.php +++ b/typo3/sysext/backend/Classes/Controller/NewRecordController.php @@ -214,7 +214,7 @@ class NewRecordController */ public function mainAction(ServerRequestInterface $request): ResponseInterface { - $response = $this->renderContent(); + $response = $this->renderContent($request); if (empty($response)) { $response = new HtmlResponse($this->moduleTemplate->renderContent()); @@ -232,7 +232,7 @@ class NewRecordController { trigger_error('Method main() will be replaced by protected method renderContent() in v10. Do not call from other extension', E_USER_DEPRECATED); - $response = $this->renderContent(); + $response = $this->renderContent($GLOBALS['TYPO3_REQUEST']); if ($response instanceof RedirectResponse) { HttpUtility::redirect($response->getHeaders()['location'][0]); @@ -258,7 +258,7 @@ class NewRecordController public function regularNew() { trigger_error('Method regularNew() will be replaced by protected method renderNewRecordControls() in v10. Do not call from other extension', E_USER_DEPRECATED); - $this->renderNewRecordControls(); + $this->renderNewRecordControls($GLOBALS['TYPO3_REQUEST']); } /** @@ -410,9 +410,10 @@ class NewRecordController /** * Main processing, creating the list of new record tables to select from * + * @param ServerRequestInterface $request * @return ResponseInterface|null */ - protected function renderContent(): ?ResponseInterface + protected function renderContent(ServerRequestInterface $request): ?ResponseInterface { // If there was a page - or if the user is admin (admins has access to the root) we proceed: if (!empty($this->pageinfo['uid']) || $this->getBackendUserAuthentication()->isAdmin()) { @@ -463,7 +464,7 @@ class NewRecordController // GENERATE the HTML-output depending on mode (pagesOnly is the page wizard) // Regular new element: if (!$this->pagesOnly) { - $this->renderNewRecordControls(); + $this->renderNewRecordControls($request); } elseif ($this->isRecordCreationAllowedForTable('pages')) { // Pages only wizard $response = $this->renderPositionTree(); @@ -606,8 +607,10 @@ class NewRecordController /** * Render controls for creating a regular new element (pages or records) + * + * @param ServerRequestInterface $request */ - protected function renderNewRecordControls(): void + protected function renderNewRecordControls(ServerRequestInterface $request): void { $lang = $this->getLanguageService(); // Initialize array for accumulating table rows: @@ -705,7 +708,7 @@ class NewRecordController $table, $this->id ); - // If the table is 'tt_content', create link to wizard + // If the table is 'tt_content', add link to wizard if ($table === 'tt_content') { $groupName = $lang->getLL('createNewContent'); $rowContent = $newContentIcon @@ -714,7 +717,9 @@ class NewRecordController // If mod.newContentElementWizard.override is set, use that extension's wizard instead: $tsConfig = BackendUtility::getModTSconfig($this->id, 'mod'); $moduleName = $tsConfig['properties']['newContentElementWizard.']['override'] ?? 'new_content_element_wizard'; - $url = (string)$uriBuilder->buildUriFromRoute($moduleName, ['id' => $this->id, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')]); + /** @var \TYPO3\CMS\Core\Http\NormalizedParams */ + $normalizedParams = $request->getAttribute('normalizedParams'); + $url = (string)$uriBuilder->buildUriFromRoute($moduleName, ['id' => $this->id, 'returnUrl' => $normalizedParams->getRequestUri()]); $rowContent .= '<li>' . $newLink . ' ' . BackendUtility::wrapInHelp($table, '') . '</li>' . '<li>' . '<a href="#" data-url="' . htmlspecialchars($url) . '" data-title="' . htmlspecialchars($this->getLanguageService()->getLL('newContentElement')) . '" class="t3js-toggle-new-content-element-wizard">' -- GitLab