Commit cbaec8e0 authored by Romain Canon's avatar Romain Canon Committed by Andreas Fernandez
Browse files

[TASK] Remove context service from install tool

This service was not useful anymore as the install tool modules handling
changed.

It is replaced by a single string that allows doing basically the same
job.

Resolves: #82353
Releases: master
Change-Id: I34e28e0d1a716b293897f54f7f800e5e6fb8e0c5
Reviewed-on: https://review.typo3.org/53966

Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Matthias Vogel's avatarMatthias Vogel <typo3@kanti.de>
Tested-by: Matthias Vogel's avatarMatthias Vogel <typo3@kanti.de>
Reviewed-by: default avatarSimon Praetorius <simon@praetorius.me>
Tested-by: default avatarSimon Praetorius <simon@praetorius.me>
Reviewed-by: default avatarStefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: default avatarStefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <typo3@scripting-base.de>
parent 450f1bbe
......@@ -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) {
......
......@@ -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;
}
}
/**
......
......@@ -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
*/
......
......@@ -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());
......
......@@ -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);
......
......@@ -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());
}
......
<?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';
}
}
......@@ -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;">
......
......@@ -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>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment