mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-01 10:56:08 +01:00
Show any configuration item Grav finds under user/config, if there is an associated blueprint provided
Also, organize current system/site/info files under a common config.html.twig. Delete info/site/system twig files. Preserve BC by setting the template of system/site/info to "config", in the pages.
This commit is contained in:
@@ -335,6 +335,15 @@ class Admin
|
||||
$obj = User::load(preg_replace('|users/|', '', $type));
|
||||
$obj->merge($post);
|
||||
|
||||
$data[$type] = $obj;
|
||||
} elseif (preg_match('|config/|', $type)) {
|
||||
$type = preg_replace('|config/|', '', $type);
|
||||
$blueprints = $this->blueprints("config/{$type}");
|
||||
$config = $this->grav['config'];
|
||||
$obj = new Data\Data($config->get($type), $blueprints);
|
||||
$obj->merge($post);
|
||||
$file = CompiledYamlFile::instance($this->grav['locator']->findResource("config://{$type}.yaml"));
|
||||
$obj->file($file);
|
||||
$data[$type] = $obj;
|
||||
} else {
|
||||
throw new \RuntimeException("Data type '{$type}' doesn't exist!");
|
||||
@@ -706,6 +715,29 @@ class Admin
|
||||
return $languages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the configuration files found
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function configurations()
|
||||
{
|
||||
$configurations = [];
|
||||
$path = $this->grav['locator']->findResource('user://config');
|
||||
|
||||
/** @var \DirectoryIterator $directory */
|
||||
foreach (new \DirectoryIterator($path) as $file) {
|
||||
if ($file->isDir() || $file->isDot() || $file->getBasename()[0] == '.') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$configurations[] = basename($file->getBasename(), '.yaml');
|
||||
|
||||
}
|
||||
|
||||
return $configurations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the languages available in the site
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user