Make room to load theme options from files

For example:
form: path/to/fields.yaml
This commit is contained in:
Samuel Georges 2016-03-22 20:03:00 +11:00
parent 31f74adb70
commit 0b74734fae
2 changed files with 21 additions and 3 deletions

View File

@ -302,6 +302,23 @@ class Theme
return array_get($this->getConfig(), $name, $default);
}
/**
* Returns an array value from the theme configuration file by its name.
* If the value is a string, it is treated as a YAML file and loaded.
* @param string $name Specifies the configuration parameter name.
* @return array
*/
public function getConfigArray($name)
{
$result = array_get($this->getConfig(), $name, []);
if (is_string($result)) {
// Load from file
}
return (array) $result;
}
/**
* Writes to the theme.yaml file with the supplied array values.
* @param array $values Data to write

View File

@ -251,16 +251,17 @@ class Themes extends Controller
{
$model = $form->model;
$theme = $this->findThemeObject($model->theme);
$config = $theme->getConfigArray('form');
if ($fields = $theme->getConfigValue('form.fields')) {
if ($fields = array_get($config, 'fields')) {
$form->addFields($fields);
}
if ($fields = $theme->getConfigValue('form.tabs.fields')) {
if ($fields = array_get($config, 'tabs.fields')) {
$form->addTabFields($fields);
}
if ($fields = $theme->getConfigValue('form.secondaryTabs.fields')) {
if ($fields = array_get($config, 'secondaryTabs.fields')) {
$form->addSecondaryTabFields($fields);
}
}