[CORE] Fix loading of settings from modules
This commit is contained in:
parent
019ad794d1
commit
cd470cbf93
@ -236,16 +236,17 @@ class GNUsocial implements EventSubscriberInterface
|
|||||||
// Load .local
|
// Load .local
|
||||||
$loader->load($local_file);
|
$loader->load($local_file);
|
||||||
$locals = $container->getParameter('locals');
|
$locals = $container->getParameter('locals');
|
||||||
|
$container->getParameterBag()->remove('locals');
|
||||||
|
|
||||||
// Load normal config
|
// Load normal config
|
||||||
$loader->load(INSTALLDIR . '/social' . Kernel::CONFIG_EXTS, 'glob');
|
$loader->load(INSTALLDIR . '/social' . Kernel::CONFIG_EXTS, 'glob');
|
||||||
$container->setParameter('gnusocial_defaults', $container->getParameter('gnusocial'));
|
$defaults = $container->getParameter('gnusocial');
|
||||||
|
|
||||||
// Load module config
|
// Load module config
|
||||||
$parameters = ModuleManager::configureContainer($container, $loader);
|
$module_configs = ModuleManager::configureContainer($container, $loader);
|
||||||
|
|
||||||
// Merge parameter $from with values already set in $to
|
// Merge parameter $from with values already set in $to
|
||||||
$merge_config = function ($from, $to = null) use ($container, $locals) {
|
$merge_local_config = function ($from, $to = null) use ($container, $locals) {
|
||||||
$to ??= $from;
|
$to ??= $from;
|
||||||
$wrapper = $container->hasParameter($to) ? $container->getParameter($to) : [];
|
$wrapper = $container->hasParameter($to) ? $container->getParameter($to) : [];
|
||||||
$content = [$from => $container->getParameter($from)];
|
$content = [$from => $container->getParameter($from)];
|
||||||
@ -257,11 +258,15 @@ class GNUsocial implements EventSubscriberInterface
|
|||||||
|
|
||||||
// Override and merge any of the previous settings from the locals
|
// Override and merge any of the previous settings from the locals
|
||||||
if (\is_array($locals)) {
|
if (\is_array($locals)) {
|
||||||
$merge_config('gnusocial');
|
$merge_local_config('gnusocial');
|
||||||
foreach ($parameters as $mod => $type) {
|
foreach ($module_configs as $mod => $type) {
|
||||||
$merge_config($mod, $type);
|
$loader->load(INSTALLDIR . \PATH_SEPARATOR . $type . \PATH_SEPARATOR . ucfirst($mod) . 'config' . Kernel::CONFIG_EXTS, 'glob');
|
||||||
|
$defaults[$mod] = $container->getParameter($mod);
|
||||||
|
$merge_local_config($mod, $type); // TODO likely broken
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$container->setParameter('gnusocial_defaults', $defaults);
|
||||||
|
$container->setParameter('gnusocial', $defaults);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -196,18 +196,18 @@ class ModuleManager
|
|||||||
}
|
}
|
||||||
$container->loadFromExtension('twig', ['paths' => $templates]);
|
$container->loadFromExtension('twig', ['paths' => $templates]);
|
||||||
|
|
||||||
$modules = array_merge(glob(INSTALLDIR . '/components/*'), glob(INSTALLDIR . '/plugins/*'));
|
$modules = array_merge(glob(INSTALLDIR . '/components/*'), glob(INSTALLDIR . '/plugins/*'));
|
||||||
$parameters = [];
|
$module_configs = [];
|
||||||
foreach ($modules as $mod) {
|
foreach ($modules as $mod) {
|
||||||
$path = "{$mod}/config" . Kernel::CONFIG_EXTS;
|
$path = "{$mod}/config" . Kernel::CONFIG_EXTS;
|
||||||
$loader->load($path, 'glob'); // Is supposed to, but doesn't return anything that would let us identify if loading worked
|
$loader->load($path, 'glob'); // Is supposed to, but doesn't return anything that would let us identify if loading worked
|
||||||
foreach (explode(',', mb_substr(Kernel::CONFIG_EXTS, 2, -1)) as $ext) {
|
foreach (explode(',', mb_substr(Kernel::CONFIG_EXTS, 2, -1)) as $ext) {
|
||||||
if (file_exists("{$mod}/config.{$ext}")) {
|
if (file_exists("{$mod}/config.{$ext}")) {
|
||||||
$parameters[basename(mb_strtolower($mod))] = basename(\dirname(mb_strtolower($mod)));
|
$module_configs[basename(mb_strtolower($mod))] = basename(\dirname(mb_strtolower($mod)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $parameters;
|
return $module_configs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user