‪TYPO3CMS  9.5
AjaxController.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
19 use Psr\Http\Message\ServerRequestInterface;
25 
32 {
37 
41  protected ‪$moduleLoader;
42 
47 
53  {
54  $this->configurationService = ‪$configurationService
55  ??
56  GeneralUtility::makeInstance(ConfigurationService::class);
57  $this->adminPanelModuleConfiguration = ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules'] ?? [];
58  $this->moduleLoader = ‪$moduleLoader ?? GeneralUtility::makeInstance(ModuleLoader::class);
59  }
60 
67  public function ‪saveDataAction(ServerRequestInterface $request): ‪JsonResponse
68  {
69  $this->configurationService->saveConfiguration(
70  $this->moduleLoader->validateSortAndInitializeModules($this->adminPanelModuleConfiguration),
71  $request
72  );
73  return new ‪JsonResponse(['success' => true]);
74  }
75 
81  public function ‪toggleActiveState(): ‪JsonResponse
82  {
83  $backendUser = $this->‪getBackendUser();
84  if ($backendUser->uc['AdminPanel']['display_top'] ?? false) {
85  $backendUser->uc['AdminPanel']['display_top'] = false;
86  } else {
87  $backendUser->uc['AdminPanel']['display_top'] = true;
88  }
89  $backendUser->writeUC();
90  return new ‪JsonResponse(['success' => true]);
91  }
92 
99  {
100  return ‪$GLOBALS['BE_USER'];
101  }
102 }
‪TYPO3\CMS\Adminpanel\Controller
Definition: AjaxController.php:4
‪TYPO3\CMS\Adminpanel\Service\ModuleLoader
Definition: ModuleLoader.php:32
‪TYPO3\CMS\Adminpanel\Controller\AjaxController\getBackendUser
‪BackendUserAuthentication getBackendUser()
Definition: AjaxController.php:95
‪TYPO3\CMS\Adminpanel\Service\ConfigurationService
Definition: ConfigurationService.php:33
‪TYPO3\CMS\Adminpanel\Controller\AjaxController\__construct
‪__construct(ConfigurationService $configurationService=null, ModuleLoader $moduleLoader=null)
Definition: AjaxController.php:49
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:45
‪TYPO3\CMS\Adminpanel\Controller\AjaxController
Definition: AjaxController.php:32
‪TYPO3\CMS\Adminpanel\Controller\AjaxController\$adminPanelModuleConfiguration
‪array $adminPanelModuleConfiguration
Definition: AjaxController.php:35
‪TYPO3\CMS\Adminpanel\Controller\AjaxController\saveDataAction
‪JsonResponse saveDataAction(ServerRequestInterface $request)
Definition: AjaxController.php:64
‪TYPO3\CMS\Adminpanel\Controller\AjaxController\toggleActiveState
‪JsonResponse toggleActiveState()
Definition: AjaxController.php:78
‪TYPO3\CMS\Core\Http\JsonResponse
Definition: JsonResponse.php:25
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Adminpanel\Controller\AjaxController\$moduleLoader
‪ModuleLoader $moduleLoader
Definition: AjaxController.php:39
‪TYPO3\CMS\Adminpanel\Controller\AjaxController\$configurationService
‪ConfigurationService $configurationService
Definition: AjaxController.php:43