diff --git a/modules/cms/classes/Theme.php b/modules/cms/classes/Theme.php index 05e15ecde..7f84c4d7d 100644 --- a/modules/cms/classes/Theme.php +++ b/modules/cms/classes/Theme.php @@ -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 diff --git a/modules/cms/controllers/Themes.php b/modules/cms/controllers/Themes.php index 64a6db77e..8848fbcee 100644 --- a/modules/cms/controllers/Themes.php +++ b/modules/cms/controllers/Themes.php @@ -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); } }