‪TYPO3CMS  ‪main
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 {
38  public function ‪getMainConfiguration(): array
39  {
40  return $this->‪getBackendUser()->getTSConfig()['admPanel.'] ?? [];
41  }
42 
47  public function ‪getConfigurationOption(string ‪$identifier, string $option): string
48  {
49  if (‪$identifier === '' || $option === '') {
50  throw new \InvalidArgumentException('Identifier and option may not be empty', 1532861423);
51  }
52 
53  $returnValue = $this->‪getMainConfiguration()['override.'][$identifier . '.'][$option] ?? $this->‪getBackendUser()->uc['AdminPanel'][$identifier . '_' . $option] ?? '';
54 
55  return (string)$returnValue;
56  }
57 
65  public function ‪saveConfiguration(array $modules, ServerRequestInterface $request): void
66  {
67  $configurationToSave = $request->getParsedBody()['TSFE_ADMIN_PANEL'] ?? [];
68  $beUser = $this->‪getBackendUser();
69  $this->‪triggerOnSubmitActors($modules, $request, $configurationToSave);
70 
71  $existingConfiguration = $beUser->uc['AdminPanel'] ?? [];
72  $existingConfiguration = is_array($existingConfiguration) ? $existingConfiguration : [];
73 
74  // Settings
75  $beUser->uc['AdminPanel'] = array_merge($existingConfiguration, $configurationToSave);
76  unset($beUser->uc['AdminPanel']['action']);
77  // Saving
78  $beUser->writeUC();
79  }
80 
82  {
83  return ‪$GLOBALS['BE_USER'];
84  }
85 
86  protected function ‪triggerOnSubmitActors(
87  array $modules,
88  ServerRequestInterface $request,
89  array $configurationToSave
90  ): void {
91  foreach ($modules as $module) {
92  if (
93  $module instanceof ‪OnSubmitActorInterface
94  && (
95  ($module instanceof ‪ConfigurableInterface && $module->‪isEnabled())
96  || !($module instanceof ‪ConfigurableInterface)
97  )
98  ) {
99  $module->onSubmit($configurationToSave, $request);
100  }
101  if ($module instanceof ‪SubmoduleProviderInterface) {
102  $this->‪triggerOnSubmitActors($module->getSubModules(), $request, $configurationToSave);
103  }
104  }
105  }
106 }
‪TYPO3\CMS\Adminpanel\ModuleApi\ConfigurableInterface
Definition: ConfigurableInterface.php:29
‪TYPO3\CMS\Adminpanel\Service\ConfigurationService\getMainConfiguration
‪getMainConfiguration()
Definition: ConfigurationService.php:38
‪TYPO3\CMS\Adminpanel\ModuleApi\ConfigurableInterface\isEnabled
‪isEnabled()
‪TYPO3\CMS\Adminpanel\Service\ConfigurationService
Definition: ConfigurationService.php:34
‪TYPO3\CMS\Adminpanel\Service
Definition: ConfigurationService.php:18
‪TYPO3\CMS\Adminpanel\ModuleApi\ModuleInterface
Definition: ModuleInterface.php:26
‪TYPO3\CMS\Core\Authentication\BackendUserAuthentication
Definition: BackendUserAuthentication.php:62
‪TYPO3\CMS\Adminpanel\Service\ConfigurationService\saveConfiguration
‪saveConfiguration(array $modules, ServerRequestInterface $request)
Definition: ConfigurationService.php:65
‪TYPO3\CMS\Core\SingletonInterface
Definition: SingletonInterface.php:22
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Adminpanel\Service\ConfigurationService\getBackendUser
‪getBackendUser()
Definition: ConfigurationService.php:81
‪TYPO3\CMS\Adminpanel\ModuleApi\OnSubmitActorInterface
Definition: OnSubmitActorInterface.php:27
‪TYPO3\CMS\Adminpanel\Service\ConfigurationService\triggerOnSubmitActors
‪triggerOnSubmitActors(array $modules, ServerRequestInterface $request, array $configurationToSave)
Definition: ConfigurationService.php:86
‪TYPO3\CMS\Adminpanel\ModuleApi\SubmoduleProviderInterface
Definition: SubmoduleProviderInterface.php:30
‪TYPO3\CMS\Adminpanel\Service\ConfigurationService\getConfigurationOption
‪getConfigurationOption(string $identifier, string $option)
Definition: ConfigurationService.php:47
‪TYPO3\CMS\Webhooks\Message\$identifier
‪identifier readonly string $identifier
Definition: FileAddedMessage.php:37