mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
Merge branch 'MDL-67364-master' of git://github.com/mickhawkins/moodle
This commit is contained in:
commit
8b64627235
@ -961,12 +961,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();
|
||||
|
@ -175,4 +175,42 @@ class core_theme_config_testcase extends advanced_testcase {
|
||||
|
||||
$this->assertRegExp("/{$themerevision}_{$themesubrevision}/", $url->out(false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm that editor_scss_to_css is correctly compiling for themes with no parent.
|
||||
*/
|
||||
public function test_editor_scss_to_css_root_theme() {
|
||||
global $CFG;
|
||||
|
||||
$this->resetAfterTest();
|
||||
$theme = theme_config::load('boost');
|
||||
$editorscss = $CFG->dirroot.'/theme/boost/scss/editor.scss';
|
||||
|
||||
$this->assertTrue(file_exists($editorscss));
|
||||
$compiler = new core_scss();
|
||||
$compiler->set_file($editorscss);
|
||||
$cssexpected = $compiler->to_css();
|
||||
$cssactual = $theme->editor_scss_to_css();
|
||||
|
||||
$this->assertEquals($cssexpected, $cssactual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm that editor_scss_to_css is compiling for a child theme not overriding its parent's editor SCSS.
|
||||
*/
|
||||
public function test_editor_scss_to_css_child_theme() {
|
||||
global $CFG;
|
||||
|
||||
$this->resetAfterTest();
|
||||
$theme = theme_config::load('classic');
|
||||
$editorscss = $CFG->dirroot.'/theme/boost/scss/editor.scss';
|
||||
|
||||
$this->assertTrue(file_exists($editorscss));
|
||||
$compiler = new core_scss();
|
||||
$compiler->set_file($editorscss);
|
||||
$cssexpected = $compiler->to_css();
|
||||
$cssactual = $theme->editor_scss_to_css();
|
||||
|
||||
$this->assertEquals($cssexpected, $cssactual);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user