Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/CoreBundle/Controller/Admin/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,16 @@ public function searchSetting(Request $request, AccessUrlHelper $accessUrlHelper
$templateMapByCategory[$category][$var] = $templateMap[$var];
}
}
$settings = $manager->load($category);

// Convert category to schema alias and validate it BEFORE loading/creating the form
$schemaAlias = $manager->convertNameSpaceToService($category);

// skip unknown/legacy categories (e.g., "tools")
if (!isset($schemas[$schemaAlias])) {
continue;
}

$settings = $manager->load($category);
$form = $this->getSettingsFormFactory()->create($schemaAlias);

foreach (array_keys($settings->getParameters()) as $name) {
Expand Down Expand Up @@ -147,6 +155,17 @@ public function updateSetting(Request $request, AccessUrlHelper $accessUrlHelper
$schemaAlias = $manager->convertNameSpaceToService($namespace);

$keyword = (string) $request->query->get('keyword', '');

// Validate schema BEFORE load/create to avoid NonExistingServiceException
$schemas = $manager->getSchemas();
if (!isset($schemas[$schemaAlias])) {
$this->addFlash('warning', sprintf('Unknown settings category "%s". Showing Platform settings.', $namespace));

return $this->redirectToRoute('chamilo_platform_settings', [
'namespace' => 'platform',
]);
}

$settings = $manager->load($namespace);

$form = $this->getSettingsFormFactory()->create(
Expand Down Expand Up @@ -193,7 +212,6 @@ public function updateSetting(Request $request, AccessUrlHelper $accessUrlHelper
]);
}

$schemas = $manager->getSchemas();
[$ordered, $labelMap] = $this->computeOrderedNamespacesByTranslatedLabel($schemas, $request);

$templateMap = [];
Expand Down
Loading