mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2026-05-05 22:45:37 +02:00
Handle special case of media configuration (#638)
* Handle special case of media configuration Since it's a list of dynamically generated entries, without parent, we cannot merge in the post data with the defaults, or the defaults are always saved, and we cannot remove existing fields * Correctly handle reading and saving * Improve implementation
This commit is contained in:
committed by
Andy Miller
parent
ebcd52803a
commit
45e9e77179
@@ -328,8 +328,15 @@ class Admin
|
||||
$type = preg_replace('|config/|', '', $type);
|
||||
$blueprints = $this->blueprints("config/{$type}");
|
||||
$config = $this->grav['config'];
|
||||
$obj = new Data\Data($config->get($type, []), $blueprints);
|
||||
|
||||
if ($type === 'media' && count($post)) {
|
||||
$obj = new Data\Data([], $blueprints); // saving
|
||||
} else {
|
||||
$obj = new Data\Data($config->get($type, []), $blueprints);
|
||||
}
|
||||
|
||||
$obj->merge($post);
|
||||
|
||||
// FIXME: We shouldn't allow user to change configuration files in system folder!
|
||||
$filename = $this->grav['locator']->findResource("config://{$type}.yaml")
|
||||
?: $this->grav['locator']->findResource("config://{$type}.yaml", true, true);
|
||||
|
||||
Reference in New Issue
Block a user