‪TYPO3CMS  11.5
GlobalVariableProvider.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 
23 
25 {
31  protected array ‪$blindedConfigurationOptions = [
32  'TYPO3_CONF_VARS' => [
33  'BE' => [
34  'installToolPassword' => '******',
35  ],
36  'DB' => [
37  'database' => '******',
38  'host' => '******',
39  'password' => '******',
40  'port' => '******',
41  'socket' => '******',
42  'username' => '******',
43  'Connections' => [
44  'Default' => [
45  'dbname' => '******',
46  'host' => '******',
47  'password' => '******',
48  'port' => '******',
49  'user' => '******',
50  'unix_socket' => '******',
51  ],
52  ],
53  ],
54  'HTTP' => [
55  'cert' => '******',
56  'ssl_key' => '******',
57  ],
58  'MAIL' => [
59  'dsn' => '******',
60  'transport_smtp_encrypt' => '******',
61  'transport_smtp_password' => '******',
62  'transport_smtp_server' => '******',
63  'transport_smtp_username' => '******',
64  ],
65  'SYS' => [
66  'encryptionKey' => '******',
67  ],
68  ],
69  ];
70 
76  protected string ‪$globalVariableKey;
77 
78  public function ‪__invoke(array $attributes): self
79  {
80  parent::__invoke($attributes);
81 
82  if (!($attributes['globalVariableKey'] ?? false)) {
83  throw new \RuntimeException('Attribute \'globalVariableKey\' must be set to use ' . __CLASS__, 1606478088);
84  }
85 
86  $this->globalVariableKey = $attributes['globalVariableKey'];
87  return $this;
88  }
89 
90  public function ‪getConfiguration(): array
91  {
92  $configurationArray = ‪$GLOBALS[‪$this->globalVariableKey] ?? [];
94 
95  // Hook for Processing blindedConfigurationOptions
96  foreach (‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][ConfigurationController::class]['modifyBlindedConfigurationOptions'] ?? [] as $classReference) {
97  $processingObject = GeneralUtility::makeInstance($classReference);
98  ‪$blindedConfigurationOptions = $processingObject->modifyBlindedConfigurationOptions(‪$blindedConfigurationOptions, $this);
99  }
100 
101  if (isset(‪$blindedConfigurationOptions[$this->globalVariableKey])) {
102  // Prepare blinding for all database connection types
103  foreach (array_keys(‪$GLOBALS['TYPO3_CONF_VARS']['DB']['Connections']) as $connectionName) {
104  if ($connectionName !== 'Default') {
105  ‪$blindedConfigurationOptions['TYPO3_CONF_VARS']['DB']['Connections'][$connectionName] =
106  ‪$blindedConfigurationOptions['TYPO3_CONF_VARS']['DB']['Connections']['Default'];
107  }
108  }
110  $configurationArray,
111  ‪ArrayUtility::intersectRecursive(‪$blindedConfigurationOptions[$this->globalVariableKey], $configurationArray)
112  );
113  }
114  ‪ArrayUtility::naturalKeySortRecursive($configurationArray);
115  return $configurationArray;
116  }
117 }
‪TYPO3\CMS\Lowlevel\ConfigurationModuleProvider\GlobalVariableProvider\getConfiguration
‪getConfiguration()
Definition: GlobalVariableProvider.php:90
‪TYPO3\CMS\Lowlevel\ConfigurationModuleProvider\GlobalVariableProvider\__invoke
‪__invoke(array $attributes)
Definition: GlobalVariableProvider.php:78
‪TYPO3\CMS\Core\Utility\ArrayUtility\mergeRecursiveWithOverrule
‪static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=true, $includeEmptyValues=true, $enableUnsetFeature=true)
Definition: ArrayUtility.php:654
‪TYPO3\CMS\Lowlevel\ConfigurationModuleProvider\AbstractProvider
Definition: AbstractProvider.php:27
‪TYPO3\CMS\Lowlevel\ConfigurationModuleProvider\GlobalVariableProvider\$blindedConfigurationOptions
‪array $blindedConfigurationOptions
Definition: GlobalVariableProvider.php:31
‪TYPO3\CMS\Core\Utility\ArrayUtility\intersectRecursive
‪static array intersectRecursive(array $source, array $mask=[])
Definition: ArrayUtility.php:569
‪TYPO3\CMS\Lowlevel\ConfigurationModuleProvider
Definition: AbstractProvider.php:18
‪TYPO3\CMS\Lowlevel\ConfigurationModuleProvider\GlobalVariableProvider\$globalVariableKey
‪string $globalVariableKey
Definition: GlobalVariableProvider.php:76
‪TYPO3\CMS\Lowlevel\ConfigurationModuleProvider\GlobalVariableProvider
Definition: GlobalVariableProvider.php:25
‪TYPO3\CMS\Core\Utility\ArrayUtility
Definition: ArrayUtility.php:24
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Utility\ArrayUtility\naturalKeySortRecursive
‪static bool naturalKeySortRecursive(array &$array)
Definition: ArrayUtility.php:831
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Lowlevel\Controller\ConfigurationController
Definition: ConfigurationController.php:38