Make room to load theme options from files
For example: form: path/to/fields.yaml
This commit is contained in:
parent
31f74adb70
commit
0b74734fae
|
|
@ -302,6 +302,23 @@ class Theme
|
||||||
return array_get($this->getConfig(), $name, $default);
|
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.
|
* Writes to the theme.yaml file with the supplied array values.
|
||||||
* @param array $values Data to write
|
* @param array $values Data to write
|
||||||
|
|
|
||||||
|
|
@ -251,16 +251,17 @@ class Themes extends Controller
|
||||||
{
|
{
|
||||||
$model = $form->model;
|
$model = $form->model;
|
||||||
$theme = $this->findThemeObject($model->theme);
|
$theme = $this->findThemeObject($model->theme);
|
||||||
|
$config = $theme->getConfigArray('form');
|
||||||
|
|
||||||
if ($fields = $theme->getConfigValue('form.fields')) {
|
if ($fields = array_get($config, 'fields')) {
|
||||||
$form->addFields($fields);
|
$form->addFields($fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($fields = $theme->getConfigValue('form.tabs.fields')) {
|
if ($fields = array_get($config, 'tabs.fields')) {
|
||||||
$form->addTabFields($fields);
|
$form->addTabFields($fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($fields = $theme->getConfigValue('form.secondaryTabs.fields')) {
|
if ($fields = array_get($config, 'secondaryTabs.fields')) {
|
||||||
$form->addSecondaryTabFields($fields);
|
$form->addSecondaryTabFields($fields);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue