‪TYPO3CMS  11.5
ConfigurationService.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;
27 
34 {
40  public function ‪getMainConfiguration(): array
41  {
42  return $this->‪getBackendUser()->‪getTSConfig()['admPanel.'] ?? [];
43  }
44 
53  public function ‪getConfigurationOption(string $identifier, string $option): string
54  {
55  if ($identifier === '' || $option === '') {
56  throw new \InvalidArgumentException('Identifier and option may not be empty', 1532861423);
57  }
58 
59  $returnValue = $this->‪getMainConfiguration()['override.'][$identifier . '.'][$option] ?? $this->‪getBackendUser()->uc['AdminPanel'][$identifier . '_' . $option] ?? '';
60 
61  return (string)$returnValue;
62  }
63 
72  public function ‪saveConfiguration(array $modules, ServerRequestInterface $request): void
73  {
74  $configurationToSave = $request->getParsedBody()['TSFE_ADMIN_PANEL'] ?? [];
75  $beUser = $this->‪getBackendUser();
76  $this->‪triggerOnSubmitActors($modules, $request, $configurationToSave);
77 
78  $existingConfiguration = $beUser->uc['AdminPanel'] ?? [];
79  $existingConfiguration = is_array($existingConfiguration) ? $existingConfiguration : [];
80 
81  // Settings
82  $beUser->uc['AdminPanel'] = array_merge($existingConfiguration, $configurationToSave);
83  unset($beUser->uc['AdminPanel']['action']);
84  // Saving
85  $beUser->writeUC();
86  }
87 
94  {
95  return ‪$GLOBALS['BE_USER'];
96  }
97 
103  protected function ‪triggerOnSubmitActors(
104  array $modules,
105  ServerRequestInterface $request,
106  $configurationToSave
107  ): void {
108  foreach ($modules as $module) {
109  if (
110  $module instanceof ‪OnSubmitActorInterface
111  && (
112  ($module instanceof ‪ConfigurableInterface && $module->‪isEnabled())
113  || !($module instanceof ‪ConfigurableInterface)
114  )
115  ) {
116  $module->onSubmit($configurationToSave, $request);
117  }
118  if ($module instanceof ‪SubmoduleProviderInterface) {
119  $this->‪triggerOnSubmitActors($module->getSubModules(), $request, $configurationToSave);
120  }
121  }
122  }
123 }
‪TYPO3\CMS\Backend\FrontendBackendUserAuthentication
Definition: FrontendBackendUserAuthentication.php:31
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication\getTSConfig
‪array getTSConfig()
Definition: BackendUserAuthentication.php:1000
‪TYPO3\CMS\Adminpanel\Service\ConfigurationService\getMainConfiguration
‪array getMainConfiguration()
Definition: ConfigurationService.php:40
‪TYPO3\CMS\Adminpanel\ModuleApi\ConfigurableInterface
Definition: ConfigurableInterface.php:29
‪TYPO3\CMS\Adminpanel\Service\ConfigurationService\triggerOnSubmitActors
‪triggerOnSubmitActors(array $modules, ServerRequestInterface $request, $configurationToSave)
Definition: ConfigurationService.php:103
‪TYPO3\CMS\Adminpanel\Service\ConfigurationService\getBackendUser
‪BackendUserAuthentication FrontendBackendUserAuthentication getBackendUser()
Definition: ConfigurationService.php:93
‪TYPO3\CMS\Adminpanel\ModuleApi\ConfigurableInterface\isEnabled
‪bool isEnabled()
‪TYPO3\CMS\Adminpanel\Service\ConfigurationService
Definition: ConfigurationService.php:34
‪TYPO3\CMS\Adminpanel\Service\ConfigurationService\getConfigurationOption
‪string getConfigurationOption(string $identifier, string $option)
Definition: ConfigurationService.php:53
‪TYPO3\CMS\Adminpanel\Service
Definition: ConfigurationService.php:18
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Adminpanel\Service\ConfigurationService\saveConfiguration
‪saveConfiguration(array $modules, ServerRequestInterface $request)
Definition: ConfigurationService.php:72
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:22
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Adminpanel\ModuleApi\OnSubmitActorInterface
Definition: OnSubmitActorInterface.php:27
‪TYPO3\CMS\Adminpanel\ModuleApi\SubmoduleProviderInterface
Definition: SubmoduleProviderInterface.php:30