[BUGFIX] Show loading label while scanning broken extensions
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Functional / Framework / Frontend / Hook / BackendUserHandler.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Functional\Framework\Frontend\Hook;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Database\ConnectionPool;
18 use TYPO3\CMS\Core\Utility\GeneralUtility;
19
20 /**
21 * Handler for backend user
22 */
23 class BackendUserHandler implements \TYPO3\CMS\Core\SingletonInterface
24 {
25 /**
26 * @param array $parameters
27 * @param \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $frontendController
28 */
29 public function initialize(array $parameters, \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $frontendController)
30 {
31 $backendUserId = (int)GeneralUtility::_GP('backendUserId');
32 $workspaceId = (int)GeneralUtility::_GP('workspaceId');
33
34 if (empty($backendUserId) || empty($workspaceId)) {
35 return;
36 }
37
38 $backendUser = $this->createBackendUser();
39 $backendUser->user = GeneralUtility::makeInstance(ConnectionPool::class)
40 ->getConnectionForTable('be_users')
41 ->select(['*'], 'be_users', ['uid' => $backendUserId])
42 ->fetch();
43 $backendUser->setTemporaryWorkspace($workspaceId);
44 $frontendController->beUserLogin = true;
45
46 $parameters['BE_USER'] = $backendUser;
47 $GLOBALS['BE_USER'] = $backendUser;
48 }
49
50 /**
51 * @return \TYPO3\CMS\Backend\FrontendBackendUserAuthentication
52 */
53 protected function createBackendUser()
54 {
55 return GeneralUtility::makeInstance(
56 \TYPO3\CMS\Backend\FrontendBackendUserAuthentication::class
57 );
58 }
59 }