/** * Validate data before storage. * * @param string $data The data. * @return mixed True if validated, else an error string. */ public function validate($data) { if (empty($data)) { return true; } try { theme_boost_parse_scss_variables($data, false); } catch (moodle_exception $e) { return $e->getMessage(); } return true; }
/** * Get additional SCSS variables. * * @param theme_config $theme The theme config object. * @return array */ function theme_boost_get_scss_variables($theme) { $variables = []; $configurable = ['brandcolor' => ['brand-primary']]; foreach ($configurable as $configkey => $targets) { $value = $theme->settings->{$configkey}; if (empty($value)) { continue; } array_map(function ($target) use(&$variables, $value) { $variables[$target] = $value; }, (array) $targets); } if (!empty($theme->settings->scss_variables)) { $variables = array_merge($variables, theme_boost_parse_scss_variables($theme->settings->scss_variables)); } return $variables; }