diff --git a/library/Icinga/Application/Hook/ThemeLoaderHook.php b/library/Icinga/Application/Hook/ThemeLoaderHook.php new file mode 100644 index 000000000..5320dd52b --- /dev/null +++ b/library/Icinga/Application/Hook/ThemeLoaderHook.php @@ -0,0 +1,22 @@ +/public/css/themes + */ +abstract class ThemeLoaderHook +{ + /** + * Get the path for the given theme + * + * @param ?string $theme + * + * @return ?string The path or NULL if the theme is unknown + */ + abstract public function getThemeFile(?string $theme): ?string; +} diff --git a/library/Icinga/Web/StyleSheet.php b/library/Icinga/Web/StyleSheet.php index aba89b4cc..6da3fc9b0 100644 --- a/library/Icinga/Web/StyleSheet.php +++ b/library/Icinga/Web/StyleSheet.php @@ -290,6 +290,19 @@ class StyleSheet $app = Icinga::app(); if ($theme && $theme !== self::DEFAULT_THEME) { + if (Hook::has('ThemeLoader')) { + try { + $path = Hook::first('ThemeLoader')->getThemeFile($theme); + } catch (Exception $e) { + Logger::error('Failed to call ThemeLoader hook: %s', $e); + $path = null; + } + + if ($path !== null) { + return $path; + } + } + if (($pos = strpos($theme, '/')) !== false) { $moduleName = substr($theme, 0, $pos); $theme = substr($theme, $pos + 1);