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:
Flavio Copes
2016-01-03 17:53:04 +01:00
parent f34a9d7638
commit ae1b2a074c
10 changed files with 108 additions and 103 deletions

View File

@@ -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
*