mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-04-08 17:15:08 +02:00
parent
8cb0976c5b
commit
4d0e42787a
@ -77,7 +77,11 @@ class ConfigForm extends Form
|
||||
}
|
||||
|
||||
foreach ($sections as $section => $config) {
|
||||
$this->config->setSection($section, $config);
|
||||
if ($this->isEmptyConfig($config)) {
|
||||
$this->config->removeSection($section);
|
||||
} else {
|
||||
$this->config->setSection($section, $config);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->save()) {
|
||||
@ -146,6 +150,28 @@ class ConfigForm extends Form
|
||||
$config->saveIni();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether the given config is empty or has only empty values
|
||||
*
|
||||
* @param array|Config $config
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isEmptyConfig($config)
|
||||
{
|
||||
if ($config instanceof Config) {
|
||||
$config = $config->toArray();
|
||||
}
|
||||
|
||||
foreach ($config as $value) {
|
||||
if ($value !== null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform all empty values of the given array to null
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user