diff --git a/typo3/sysext/install/Classes/Controller/AbstractController.php b/typo3/sysext/install/Classes/Controller/AbstractController.php index d7e95f57639f8bc72d07bfd6b2ea223360439a34..6381d1c2a3ced190ba22a08ee0da65ad92c55cd1 100644 --- a/typo3/sysext/install/Classes/Controller/AbstractController.php +++ b/typo3/sysext/install/Classes/Controller/AbstractController.php @@ -44,7 +44,7 @@ class AbstractController $action = GeneralUtility::makeInstance(LoginForm::class); $action->setController('common'); $action->setAction('login'); - $action->setContext($request->getAttribute('context', 'standalone')); + $action->setContext($request->getAttribute('context')); $action->setToken($this->generateTokenForAction('login')); $action->setPostValues($request->getParsedBody()['install'] ?? []); if ($message) { diff --git a/typo3/sysext/install/Classes/Controller/Action/AbstractAction.php b/typo3/sysext/install/Classes/Controller/Action/AbstractAction.php index a1fcaa1191a234e4d274403b166ea468c42e4744..11e447c7ef00df4d3b81b32da539e67b1106dd76 100644 --- a/typo3/sysext/install/Classes/Controller/Action/AbstractAction.php +++ b/typo3/sysext/install/Classes/Controller/Action/AbstractAction.php @@ -16,7 +16,6 @@ namespace TYPO3\CMS\Install\Controller\Action; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Fluid\View\StandaloneView; -use TYPO3\CMS\Install\Service\ContextService; /** * General purpose controller action helper methods and bootstrap @@ -54,9 +53,9 @@ abstract class AbstractAction implements ActionInterface protected $messages = []; /** - * @var ContextService + * @var string */ - protected $contextService; + protected $context = self::CONTEXT_STANDALONE; /** * Handles the action @@ -88,8 +87,8 @@ abstract class AbstractAction implements ActionInterface ->assign('action', $this->action) ->assign('controller', $this->controller) ->assign('token', $this->token) - ->assign('context', $this->contextService->getContextString()) - ->assign('contextService', $this->contextService) + ->assign('context', $this->context) + ->assign('backendContext', $this->context === self::CONTEXT_BACKEND) ->assign('messages', $this->messages) ->assign('typo3Version', TYPO3_version) ->assign('siteName', $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']); @@ -155,13 +154,19 @@ abstract class AbstractAction implements ActionInterface /** * Context determines if the install tool is called within backend or standalone - * This method creates a context service that distinguishes between standalone and backend context * - * @param $context string Either 'standalone' or 'backend' + * @param $context string One of the `CONTEXT_*` constants. */ public function setContext($context) { - $this->contextService = GeneralUtility::makeInstance(\TYPO3\CMS\Install\Service\ContextService::class, $context); + switch ($context) { + case self::CONTEXT_STANDALONE: + case self::CONTEXT_BACKEND: + $this->context = $context; + break; + default: + $this->context = self::CONTEXT_STANDALONE; + } } /** diff --git a/typo3/sysext/install/Classes/Controller/Action/ActionInterface.php b/typo3/sysext/install/Classes/Controller/Action/ActionInterface.php index c39096ac527cb2cb878ab3d86e97cdc1636f6ab4..9ff1d76913aca0e9ad925f8a70518f2aea3b80da 100644 --- a/typo3/sysext/install/Classes/Controller/Action/ActionInterface.php +++ b/typo3/sysext/install/Classes/Controller/Action/ActionInterface.php @@ -19,6 +19,9 @@ namespace TYPO3\CMS\Install\Controller\Action; */ interface ActionInterface { + const CONTEXT_STANDALONE = 'standalone'; + const CONTEXT_BACKEND = 'backend'; + /** * Handle this action * @@ -49,7 +52,7 @@ interface ActionInterface public function setAction($action); /** - * Set the context name, can be "installer", "standalone" or "backend" + * Set the context name, must be one of the `CONTEXT_*` constants. * * @param string $context */ diff --git a/typo3/sysext/install/Classes/Controller/AjaxController.php b/typo3/sysext/install/Classes/Controller/AjaxController.php index 8631ec678f23c2e5204edf33c2ae10ef11d2e334..ef0546734255b043c458ff4497e2f91792f0c723 100644 --- a/typo3/sysext/install/Classes/Controller/AjaxController.php +++ b/typo3/sysext/install/Classes/Controller/AjaxController.php @@ -115,7 +115,7 @@ class AjaxController extends AbstractController } $toolAction->setController('ajax'); $toolAction->setAction($action); - $toolAction->setContext($request->getAttribute('context', 'standalone')); + $toolAction->setContext($request->getAttribute('context')); $toolAction->setToken($this->generateTokenForAction($action)); $toolAction->setPostValues($request->getParsedBody()['install'] ?? []); return $this->output($toolAction->handle()); diff --git a/typo3/sysext/install/Classes/Controller/StepController.php b/typo3/sysext/install/Classes/Controller/StepController.php index 311c0c7e456c626ba86971ce3d9ebd26247cbc86..669a5d462a307771324f1eff7b7c35d86b5f3105 100644 --- a/typo3/sysext/install/Classes/Controller/StepController.php +++ b/typo3/sysext/install/Classes/Controller/StepController.php @@ -18,6 +18,7 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Install\Controller\Action\ActionInterface; use TYPO3\CMS\Install\Controller\Action\Step\AbstractStepAction; use TYPO3\CMS\Install\Service\EnableFileService; use TYPO3\CMS\Install\Service\SessionService; @@ -82,7 +83,7 @@ class StepController extends AbstractController $action = GeneralUtility::makeInstance(\TYPO3\CMS\Install\Controller\Action\Common\InstallToolDisabledAction::class); $action->setAction('installToolDisabled'); } - $action->setContext('standalone'); + $action->setContext(ActionInterface::CONTEXT_STANDALONE); $action->setController('common'); return $this->output($action->handle()); } @@ -98,7 +99,7 @@ class StepController extends AbstractController /** @var \TYPO3\CMS\Install\Controller\Action\ActionInterface $action */ $action = GeneralUtility::makeInstance(\TYPO3\CMS\Install\Controller\Action\Common\InstallToolPasswordNotSetAction::class); $action->setController('common'); - $action->setContext('standalone'); + $action->setContext(ActionInterface::CONTEXT_STANDALONE); $action->setAction('installToolPasswordNotSet'); return $this->output($action->handle()); } @@ -119,7 +120,7 @@ class StepController extends AbstractController /** @var AbstractStepAction $stepAction */ $stepAction = $this->getActionInstance($action); $stepAction->setAction($action); - $stepAction->setContext('standalone'); + $stepAction->setContext(ActionInterface::CONTEXT_STANDALONE); $stepAction->setToken($this->generateTokenForAction($action)); $stepAction->setPostValues($postValues); $messages = $stepAction->execute(); @@ -149,7 +150,7 @@ class StepController extends AbstractController $stepAction = $this->getActionInstance($action); $stepAction->setAction($action); $stepAction->setController('step'); - $stepAction->setContext('standalone'); + $stepAction->setContext(ActionInterface::CONTEXT_STANDALONE); $stepAction->setToken($this->generateTokenForAction($action)); $stepAction->setPostValues($postValues); @@ -242,7 +243,7 @@ class StepController extends AbstractController $action->setStepsCounter($currentStep, $totalSteps); } $action->setController('step'); - $action->setContext('standalone'); + $action->setContext(ActionInterface::CONTEXT_STANDALONE); $action->setAction('environmentAndFolders'); if (!empty($errorMessagesFromExecute)) { $action->setMessages($errorMessagesFromExecute); diff --git a/typo3/sysext/install/Classes/Controller/ToolController.php b/typo3/sysext/install/Classes/Controller/ToolController.php index 205329ddd7c93efe36a8343d71b3bc8587a7e941..e590b7ddc25542162953c6fff80623a55b6a5e4b 100644 --- a/typo3/sysext/install/Classes/Controller/ToolController.php +++ b/typo3/sysext/install/Classes/Controller/ToolController.php @@ -62,7 +62,7 @@ class ToolController extends AbstractController $toolAction->setController('tool'); $toolAction->setAction($action); $toolAction->setToken($this->generateTokenForAction($action)); - $toolAction->setContext($request->getAttribute('context', 'standalone')); + $toolAction->setContext($request->getAttribute('context')); $toolAction->setPostValues($request->getParsedBody()['install'] ?? []); return $this->output($toolAction->handle()); } diff --git a/typo3/sysext/install/Classes/Service/ContextService.php b/typo3/sysext/install/Classes/Service/ContextService.php deleted file mode 100644 index ca8d3311ca56c7a59a4d74ee0e311983d107fa6d..0000000000000000000000000000000000000000 --- a/typo3/sysext/install/Classes/Service/ContextService.php +++ /dev/null @@ -1,66 +0,0 @@ -<?php -namespace TYPO3\CMS\Install\Service; - -/* - * This file is part of the TYPO3 CMS project. - * - * It is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, either version 2 - * of the License, or any later version. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - * - * The TYPO3 project - inspiring people to share! - */ - -/** - * Service for determining the current context (as a backend module or in standalone mode) - */ -class ContextService -{ - /** - * @var bool - */ - private $backendContext = false; - - /** - * Constructor, prepare the context information - * - * @param string $context - */ - public function __construct($context) - { - $this->backendContext = ($context === 'backend'); - } - - /** - * Is the install tool running in the backend? - * - * @return bool - */ - public function isBackendContext() - { - return $this->backendContext; - } - - /** - * Is the install tool running as a standalone application? - * - * @return bool - */ - public function isStandaloneContext() - { - return !$this->backendContext; - } - - /** - * Is the install tool running as a standalone application? - * - * @return bool - */ - public function getContextString() - { - return $this->isBackendContext() ? 'backend' : 'standalone'; - } -} diff --git a/typo3/sysext/install/Resources/Private/Layouts/ToolAuthenticated.html b/typo3/sysext/install/Resources/Private/Layouts/ToolAuthenticated.html index fb55c2e2bd2d795a5266688e9f0bccdbf07682db..ec7b1842f0f80dddfa312dad4fbc6a2954bde517 100644 --- a/typo3/sysext/install/Resources/Private/Layouts/ToolAuthenticated.html +++ b/typo3/sysext/install/Resources/Private/Layouts/ToolAuthenticated.html @@ -5,7 +5,7 @@ <f:render partial="Action/Common/Headers" arguments="{_all}" /> </head> <body class="{context}"> -<f:if condition="{contextService.backendContext}"> +<f:if condition="{backendContext}"> <f:then> <div class="module" data-module-id="" data-module-name=""> <div class="module-docheader t3js-module-docheader" style="height: auto;"> diff --git a/typo3/sysext/install/Resources/Private/Templates/Action/Common/Login.html b/typo3/sysext/install/Resources/Private/Templates/Action/Common/Login.html index 3f2ea2e70eb6da23794150f72711f5298623afe8..7670acee6fb256bd461a65cbd526051ba8221bc4 100644 --- a/typo3/sysext/install/Resources/Private/Templates/Action/Common/Login.html +++ b/typo3/sysext/install/Resources/Private/Templates/Action/Common/Login.html @@ -15,7 +15,7 @@ <link rel="stylesheet" type="text/css" href="{f:uri.resource(path: 'Css/install.css')}?{time}" /> </head> <body class="{context}"> - <f:if condition="{contextService.backendContext}"> + <f:if condition="{backendContext}"> <div id="typo3-docheader"> <div class="typo3-docheader-functions"></div> <div class="typo3-docheader-buttons"></div>