MDL-67364 output: Allow child themes to use parent editor_scss config

This still allows child themes to override editor_scss, but will fall
back to what the parent is using if they do not specify it. This
negates the need for every child them to have the config duplicated
in order to utilise it.
This commit is contained in:
Michael Hawkins
2020-02-13 22:53:31 +08:00
parent 59f947667a
commit fa0e63f9da
+21 -2
View File
@@ -980,12 +980,31 @@ class theme_config {
*/
public function editor_scss_to_css() {
$css = '';
$dir = $this->dir;
$filenames = [];
// Use editor_scss file(s) provided by this theme if set.
if (!empty($this->editor_scss)) {
$filenames = $this->editor_scss;
} else {
// If no editor_scss set, move up theme hierarchy until one is found (if at all).
// This is so child themes only need to set editor_scss if an override is required.
foreach (array_reverse($this->parent_configs) as $parentconfig) {
if (!empty($parentconfig->editor_scss)) {
$dir = $parentconfig->dir;
$filenames = $parentconfig->editor_scss;
// Config found, stop looking.
break;
}
}
}
if (!empty($filenames)) {
$compiler = new core_scss();
foreach ($this->editor_scss as $filename) {
$compiler->set_file("{$this->dir}/scss/{$filename}.scss");
foreach ($filenames as $filename) {
$compiler->set_file("{$dir}/scss/{$filename}.scss");
try {
$css .= $compiler->to_css();