‪TYPO3CMS  10.4
AjaxController.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\ServerRequestInterface;
26 
33 {
38 
42  protected ‪$moduleLoader;
43 
48 
54  {
55  $this->configurationService = ‪$configurationService
56  ??
57  GeneralUtility::makeInstance(ConfigurationService::class);
58  $this->adminPanelModuleConfiguration = ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules'] ?? [];
59  $this->moduleLoader = ‪$moduleLoader ?? GeneralUtility::makeInstance(ModuleLoader::class);
60  }
61 
68  public function ‪saveDataAction(ServerRequestInterface $request): ‪JsonResponse
69  {
70  $this->configurationService->saveConfiguration(
71  $this->moduleLoader->validateSortAndInitializeModules($this->adminPanelModuleConfiguration),
72  $request
73  );
74  return new ‪JsonResponse(['success' => true]);
75  }
76 
82  public function ‪toggleActiveState(): ‪JsonResponse
83  {
84  $backendUser = $this->‪getBackendUser();
85  if ($backendUser->uc['AdminPanel']['display_top'] ?? false) {
86  $backendUser->uc['AdminPanel']['display_top'] = false;
87  } else {
88  $backendUser->uc['AdminPanel']['display_top'] = true;
89  }
90  $backendUser->writeUC();
91  return new ‪JsonResponse(['success' => true]);
92  }
93 
100  {
101  return ‪$GLOBALS['BE_USER'];
102  }
103 }
‪TYPO3\CMS\Adminpanel\Controller
Definition: AjaxController.php:18
‪TYPO3\CMS\Adminpanel\Service\ModuleLoader
Definition: ModuleLoader.php:33
‪TYPO3\CMS\Adminpanel\Controller\AjaxController\getBackendUser
‪BackendUserAuthentication getBackendUser()
Definition: AjaxController.php:96
‪TYPO3\CMS\Adminpanel\Service\ConfigurationService
Definition: ConfigurationService.php:34
‪TYPO3\CMS\Adminpanel\Controller\AjaxController\__construct
‪__construct(ConfigurationService $configurationService=null, ModuleLoader $moduleLoader=null)
Definition: AjaxController.php:50
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Adminpanel\Controller\AjaxController
Definition: AjaxController.php:33
‪TYPO3\CMS\Adminpanel\Controller\AjaxController\$adminPanelModuleConfiguration
‪array $adminPanelModuleConfiguration
Definition: AjaxController.php:36
‪TYPO3\CMS\Adminpanel\Controller\AjaxController\saveDataAction
‪JsonResponse saveDataAction(ServerRequestInterface $request)
Definition: AjaxController.php:65
‪TYPO3\CMS\Adminpanel\Controller\AjaxController\toggleActiveState
‪JsonResponse toggleActiveState()
Definition: AjaxController.php:79
‪TYPO3\CMS\Core\Http\JsonResponse
Definition: JsonResponse.php:26
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Adminpanel\Controller\AjaxController\$moduleLoader
‪ModuleLoader $moduleLoader
Definition: AjaxController.php:40
‪TYPO3\CMS\Adminpanel\Controller\AjaxController\$configurationService
‪ConfigurationService $configurationService
Definition: AjaxController.php:44