‪TYPO3CMS  ‪main
BackendModuleController.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\Http\Message\ResponseInterface;
21 use Psr\Http\Message\ServerRequestInterface;
27 use TYPO3\CMS\Install\Service\SessionService;
28 
41 {
42  protected ?SessionService ‪$sessionService = null;
43 
44  public function ‪__construct(
45  protected readonly ‪ModuleTemplateFactory $moduleTemplateFactory
46  ) {
47  }
48 
52  public function ‪maintenanceAction(ServerRequestInterface $request): ResponseInterface
53  {
54  return $this->‪setAuthorizedAndRedirect('maintenance', $request);
55  }
56 
60  public function ‪settingsAction(ServerRequestInterface $request): ResponseInterface
61  {
62  return $this->‪setAuthorizedAndRedirect('settings', $request);
63  }
64 
68  public function ‪upgradeAction(ServerRequestInterface $request): ResponseInterface
69  {
70  return $this->‪setAuthorizedAndRedirect('upgrade', $request);
71  }
72 
76  public function ‪environmentAction(ServerRequestInterface $request): ResponseInterface
77  {
78  return $this->‪setAuthorizedAndRedirect('environment', $request);
79  }
80 
85  protected function ‪setAuthorizedAndRedirect(string $controller, ServerRequestInterface $request): ResponseInterface
86  {
87  $userSession = $this->‪getBackendUser()->getSession();
88  $this->‪getSessionService()->setAuthorizedBackendSession($userSession);
89  $entryPointResolver = GeneralUtility::makeInstance(BackendEntryPointResolver::class);
90  $redirectLocation = $entryPointResolver->getUriFromRequest($request, 'install.php')->withQuery('?install[controller]=' . $controller . '&install[context]=backend');
91  return new ‪RedirectResponse($redirectLocation, 303);
92  }
93 
95  {
96  return ‪$GLOBALS['BE_USER'];
97  }
98 
103  protected function ‪getSessionService(): SessionService
104  {
105  if ($this->sessionService === null) {
106  $this->sessionService = new SessionService();
107  $this->sessionService->startSession();
108  }
110  }
111 }
‪TYPO3\CMS\Backend\Template\ModuleTemplateFactory
Definition: ModuleTemplateFactory.php:33
‪TYPO3\CMS\Install\Controller\BackendModuleController\settingsAction
‪settingsAction(ServerRequestInterface $request)
Definition: BackendModuleController.php:60
‪TYPO3\CMS\Install\Controller\BackendModuleController\setAuthorizedAndRedirect
‪setAuthorizedAndRedirect(string $controller, ServerRequestInterface $request)
Definition: BackendModuleController.php:85
‪TYPO3\CMS\Install\Controller\BackendModuleController\getBackendUser
‪getBackendUser()
Definition: BackendModuleController.php:94
‪TYPO3\CMS\Install\Controller\BackendModuleController\upgradeAction
‪upgradeAction(ServerRequestInterface $request)
Definition: BackendModuleController.php:68
‪TYPO3\CMS\Install\Controller\BackendModuleController\maintenanceAction
‪maintenanceAction(ServerRequestInterface $request)
Definition: BackendModuleController.php:52
‪TYPO3\CMS\Install\Controller\BackendModuleController\environmentAction
‪environmentAction(ServerRequestInterface $request)
Definition: BackendModuleController.php:76
‪TYPO3\CMS\Install\Controller\BackendModuleController\getSessionService
‪getSessionService()
Definition: BackendModuleController.php:103
‪TYPO3\CMS\Install\Controller
Definition: AbstractController.php:18
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:64
‪TYPO3\CMS\Install\Controller\BackendModuleController\__construct
‪__construct(protected readonly ModuleTemplateFactory $moduleTemplateFactory)
Definition: BackendModuleController.php:44
‪TYPO3\CMS\Core\Http\RedirectResponse
Definition: RedirectResponse.php:30
‪TYPO3\CMS\Install\Controller\BackendModuleController\$sessionService
‪SessionService $sessionService
Definition: BackendModuleController.php:42
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:51
‪TYPO3\CMS\Core\Routing\BackendEntryPointResolver
Definition: BackendEntryPointResolver.php:29
‪TYPO3\CMS\Install\Controller\BackendModuleController
Definition: BackendModuleController.php:41