2 declare(strict_types = 1);
18 use TYPO3\CMS\Core\Configuration\ConfigurationManager;
41 $configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
42 $localConfiguration = $configurationManager->getMergedLocalConfiguration();
47 foreach ($localConfiguration as $sectionName => $section) {
48 if (isset($commentArray[$sectionName])) {
49 $data[$sectionName][
'description'] = $commentArray[$sectionName][
'description'] ?? $sectionName;
52 $GLOBALS[
'TYPO3_CONF_VARS'][$sectionName] ??
null,
53 $commentArray[$sectionName]
77 foreach ($sections as $key => $value) {
78 if (!isset($descriptions[
'items'][$key])) {
83 $descriptionInfo = $descriptions[
'items'][$key];
84 $descriptionType = $descriptionInfo[
'type'];
89 if ($descriptionType ===
'container') {
90 $valueFromCurrentConfiguration = $sectionsFromCurrentConfiguration[$key] ??
null;
92 } elseif (!preg_match(
'/[' . LF . CR .
']/', (
string)$value) || $descriptionType ===
'multiline') {
94 $itemData[
'key'] = implode(
'/', $newPath);
95 $itemData[
'path'] =
'[' . implode(
'][', $newPath) .
']';
96 $itemData[
'fieldType'] = $descriptionInfo[
'type'];
97 $itemData[
'description'] = $descriptionInfo[
'description'];
98 $itemData[
'allowedValues'] = $descriptionInfo[
'allowedValues'];
99 $itemData[
'differentValueInCurrentConfiguration'] = (!isset($descriptionInfo[
'compareValuesWithCurrentConfiguration']) ||
100 $descriptionInfo[
'compareValuesWithCurrentConfiguration']) &&
101 isset($sectionsFromCurrentConfiguration[$key]) &&
102 $value !== $sectionsFromCurrentConfiguration[$key];
103 switch ($descriptionType) {
105 $itemData[
'type'] =
'textarea';
106 $itemData[
'value'] = str_replace([
'\' . LF . \
'',
'\' . LF . \
''], [LF, LF], $value);
109 $itemData[
'type'] =
'checkbox';
110 $itemData[
'value'] = $value ?
'1' :
'0';
111 $itemData[
'checked'] = (bool)$value;
114 $itemData[
'type'] =
'number';
115 $itemData[
'value'] = (int)$value;
118 $itemData[
'type'] =
'input';
120 $itemData[
'value'] = is_array($value)
121 ? implode(
',', $value)
126 $itemData[
'type'] =
'input';
127 $itemData[
'value'] = $value;
128 $itemData[
'phpErrorCode'] =
true;
131 $itemData[
'type'] =
'password';
132 $itemData[
'value'] = $value;
133 $itemData[
'hideValue'] =
true;
136 $itemData[
'type'] =
'input';
137 $itemData[
'value'] = $value;
156 $configurationPathValuePairs = [];
158 $configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
159 foreach ($valueList as $path => $value) {
160 $oldValue = $configurationManager->getConfigurationValueByPath($path);
161 $pathParts = explode(
'/', $path);
162 $descriptionData = $commentArray[$pathParts[0]];
164 while ($part = next($pathParts)) {
165 $descriptionData = $descriptionData[
'items'][$part];
168 $dataType = $descriptionData[
'type'];
170 if ($dataType ===
'multiline') {
173 $value = str_replace([CR, LF], [
'',
'\' . LF . \
''], $value);
176 if ($dataType ===
'bool') {
179 $value = $value ===
'1';
180 $valueHasChanged = (bool)$oldValue !== $value;
181 } elseif ($dataType ===
'int') {
183 $value = (int)$value;
184 $valueHasChanged = (int)$oldValue !== $value;
185 } elseif ($dataType ===
'array') {
186 $oldValueAsString = is_array($oldValue)
187 ? implode(
',', $oldValue)
189 $valueHasChanged = $oldValueAsString !== $value;
190 $value = GeneralUtility::trimExplode(
',', $value,
true);
192 $valueHasChanged = (string)$oldValue !== (
string)$value;
196 if ($valueHasChanged) {
197 $configurationPathValuePairs[$path] = $value;
199 if (is_bool($value)) {
200 $messageBody =
'New value = ' . ($value ?
'true' :
'false');
201 } elseif (empty($value)) {
202 $messageBody =
'New value = none';
203 } elseif (is_array($value)) {
204 $messageBody =
"New value = ['" . implode(
"', '", $value) .
"']";
205 } elseif ($dataType ===
'password') {
206 $messageBody =
'New value is set';
208 $messageBody =
'New value = ' . $value;
217 if (!empty($messageQueue)) {
218 $configurationManager->setLocalConfigurationValuesByPathValuePairs($configurationPathValuePairs);
220 return $messageQueue;
230 $configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class);
231 $fileName = $configurationManager->getDefaultConfigurationDescriptionFileLocation();
232 $fileLoader = GeneralUtility::makeInstance(YamlFileLoader::class);
233 return $fileLoader->load($fileName);