Commit cb513361 authored by Oliver Bartsch's avatar Oliver Bartsch
Browse files

[TASK] Use ModuleData API in ConfigurationController

The ModuleData API, introduced in #96895,
is now used in the ConfigurationController.

Additionally, to streamline the behaviour of
backend modules, the configuration module
now falls back to the first available configuration
provider, if none or an invalid provider is requested.

Resolves: #96950
Related: #96895
Releases: main
Change-Id: Ib0ca62319ee2ce696f4f1391565ffeea26d06a7f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/73584

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
parent a0d3a807
......@@ -52,54 +52,39 @@ class ConfigurationController
$backendUser = $this->getBackendUser();
$queryParams = $request->getQueryParams();
$postValues = $request->getParsedBody();
$moduleState = $backendUser->uc['moduleData']['system_config'] ?? [];
$moduleData = $request->getAttribute('moduleData');
$configurationProviderIdentifier = (string)($queryParams['tree'] ?? $moduleState['tree'] ?? '');
if ($configurationProviderIdentifier === ''
&& $this->configurationProviderRegistry->getFirstProvider() !== null
) {
$configurationProviderIdentifier = $this->configurationProviderRegistry->getFirstProvider()->getIdentifier();
}
if (!$this->configurationProviderRegistry->hasProvider($configurationProviderIdentifier)) {
throw new \InvalidArgumentException(
'No provider found for identifier: ' . $configurationProviderIdentifier,
1606306196
);
}
// Validate requested "tree"
$moduleData->clean('tree', array_keys($this->configurationProviderRegistry->getProviders()));
$configurationProviderIdentifier = $moduleData->get('tree');
$configurationProvider = $this->configurationProviderRegistry->getProvider($configurationProviderIdentifier);
$moduleState['tree'] = $configurationProviderIdentifier;
$configurationArray = $configurationProvider->getConfiguration();
// Search string given or regex search enabled?
$searchString = trim((string)($postValues['searchString'] ?? ''));
$moduleState['regexSearch'] = (bool)($postValues['regexSearch'] ?? $moduleState['regexSearch'] ?? false);
// Prepare array renderer class, apply search and expand / collapse states
$arrayBrowser = GeneralUtility::makeInstance(ArrayBrowser::class, $request->getAttribute('route'));
$arrayBrowser->regexMode = $moduleState['regexSearch'];
$arrayBrowser->regexMode = (bool)$moduleData->get('regexSearch');
$node = $queryParams['node'] ?? null;
if ($searchString) {
$arrayBrowser->depthKeys = $arrayBrowser->getSearchKeys($configurationArray, '', $searchString, []);
} elseif (is_array($node)) {
$newExpandCollapse = $arrayBrowser->depthKeys($node, $moduleState['node_' . $configurationProviderIdentifier] ?? []);
$newExpandCollapse = $arrayBrowser->depthKeys($node, $moduleData->get('node_' . $configurationProviderIdentifier, []));
$arrayBrowser->depthKeys = $newExpandCollapse;
$moduleState['node_' . $configurationProviderIdentifier] = $newExpandCollapse;
$moduleData->set('node_' . $configurationProviderIdentifier, $newExpandCollapse);
} else {
$arrayBrowser->depthKeys = $moduleState['node_' . $configurationProviderIdentifier] ?? [];
$arrayBrowser->depthKeys = $moduleData->get('node_' . $configurationProviderIdentifier, []);
}
// Store new state
$backendUser->uc['moduleData']['system_config'] = $moduleState;
$backendUser->writeUC();
// Store new moduleData state
$backendUser->pushModuleData($moduleData->getModuleIdentifier(), $moduleData->toArray());
$view->assignMultiple([
'treeName' => $configurationProvider->getLabel(),
'searchString' => $searchString,
'regexSearch' => $moduleState['regexSearch'],
'regexSearch' => (bool)$moduleData->get('regexSearch'),
'tree' => $arrayBrowser->tree($configurationArray, ''),
]);
......
......@@ -32,5 +32,9 @@ return [
'target' => ConfigurationController::class . '::handleRequest',
],
],
'moduleData' => [
'tree' => '',
'regexSearch' => false,
],
],
];
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment