diff --git a/module/VuFindTheme/src/VuFindTheme/LessCompiler.php b/module/VuFindTheme/src/VuFindTheme/LessCompiler.php index 26b7086a64acb4e5f15808166240f7f91c24a74a..ee027ba9e96cfa592695fc564c69a373b0b53282 100644 --- a/module/VuFindTheme/src/VuFindTheme/LessCompiler.php +++ b/module/VuFindTheme/src/VuFindTheme/LessCompiler.php @@ -88,17 +88,13 @@ class LessCompiler */ protected function processTheme($theme) { - $config = $this->basePath . '/themes/' . $theme . '/theme.config.php'; - if (!file_exists($config)) { - return; - } - $config = include $config; - if (!isset($config['less'])) { + $lessFiles = $this->getAllLessFiles($theme); + if (empty($lessFiles)) { Console::writeLine("No LESS in " . $theme); return; } Console::writeLine("Processing " . $theme); - foreach ($config['less'] as $less) { + foreach ($lessFiles as $less) { if (is_string($less)) { $this->compileFile($theme, $less); } @@ -108,6 +104,25 @@ class LessCompiler \Less_Cache::CleanCache(); // deletes week old files } + /** + * Get all less files that might exist in a theme. + * + * @return array + */ + protected function getAllLessFiles($theme) + { + $config = $this->basePath . '/themes/' . $theme . '/theme.config.php'; + if (!file_exists($config)) { + return array(); + } + $configArr = include $config; + $base = (isset($configArr['extends'])) + ? $this->getAllLessFiles($configArr['extends']) + : array(); + $current = isset($configArr['less']) ? $configArr['less'] : array(); + return array_merge($base, $current); + } + /** * Compile a LESS file inside a theme. * @@ -132,6 +147,12 @@ class LessCompiler = $this->fakePath . "themes/$curTheme/css/less"; } $lessDir = $this->basePath . '/themes/' . $theme . '/less/'; + if (!file_exists($lessDir . $less)) { + Console::writeLine( + "\t\t" . $lessDir . $less . ' does not exist; skipping.' + ); + return; + } $outDir = sys_get_temp_dir(); $outFile = \Less_Cache::Regen( array($lessDir . $less => $this->fakePath . "themes/$theme/css/less"),