[CONFIG] Fix error on missing or empty local configuration

This commit is contained in:
Hugo Sales 2020-09-30 22:52:01 +00:00 committed by Hugo Sales
parent 02c7bdf4f0
commit a9944592c4
1 changed files with 10 additions and 4 deletions

View File

@ -104,12 +104,18 @@ class Kernel extends BaseKernel
$loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob'); $loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob');
// Overriding doesn't work as we want, overrides the top-most key, do it manually // Overriding doesn't work as we want, overrides the top-most key, do it manually
$loader->load(INSTALLDIR . '/social.local' . self::CONFIG_EXTS, 'glob'); $local_file = INSTALLDIR . '/social.local.yaml';
if (!file_exists($local_file)) {
file_put_contents($local_file, "parameters:\n gnusocial:\n");
}
$loader->load($local_file);
$locals = $container->getParameter('gnusocial'); $locals = $container->getParameter('gnusocial');
$loader->load(INSTALLDIR . '/social' . self::CONFIG_EXTS, 'glob'); $loader->load(INSTALLDIR . '/social' . self::CONFIG_EXTS, 'glob');
$defaults = $container->getParameter('gnusocial'); $container->setParameter('gnusocial_defaults', $defaults = $container->getParameter('gnusocial'));
$configs = array_replace_recursive($defaults, $locals); if (is_array($locals)) {
$container->setParameter('gnusocial', $configs); $configs = array_replace_recursive($defaults, $locals);
$container->setParameter('gnusocial', $configs);
}
} }
protected function configureRoutes(RoutingConfigurator $routes): void protected function configureRoutes(RoutingConfigurator $routes): void