‪TYPO3CMS  11.5
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 
50  {
51  $this->configurationService = ‪$configurationService
52  ??
53  GeneralUtility::makeInstance(ConfigurationService::class);
54  $this->adminPanelModuleConfiguration = ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules'] ?? [];
55  $this->moduleLoader = ‪$moduleLoader ?? GeneralUtility::makeInstance(ModuleLoader::class);
56  }
57 
64  public function ‪saveDataAction(ServerRequestInterface $request): ‪JsonResponse
65  {
66  $this->configurationService->saveConfiguration(
67  $this->moduleLoader->validateSortAndInitializeModules($this->adminPanelModuleConfiguration),
68  $request
69  );
70  return new ‪JsonResponse(['success' => true]);
71  }
72 
78  public function ‪toggleActiveState(): ‪JsonResponse
79  {
80  $backendUser = $this->‪getBackendUser();
81  if ($backendUser->uc['AdminPanel']['display_top'] ?? false) {
82  $backendUser->uc['AdminPanel']['display_top'] = false;
83  } else {
84  $backendUser->uc['AdminPanel']['display_top'] = true;
85  }
86  $backendUser->writeUC();
87  return new ‪JsonResponse(['success' => true]);
88  }
89 
96  {
97  return ‪$GLOBALS['BE_USER'];
98  }
99 }
‪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:92
‪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:46
‪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:61
‪TYPO3\CMS\Adminpanel\Controller\AjaxController\toggleActiveState
‪JsonResponse toggleActiveState()
Definition: AjaxController.php:75
‪TYPO3\CMS\Core\Http\JsonResponse
Definition: JsonResponse.php:28
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Adminpanel\Controller\AjaxController\$moduleLoader
‪ModuleLoader $moduleLoader
Definition: AjaxController.php:40
‪TYPO3\CMS\Adminpanel\Controller\AjaxController\$configurationService
‪ConfigurationService $configurationService
Definition: AjaxController.php:44