Skip to content

NOW MANAGED ON CODEBERG

Theme: Updated view registration to be dynamic

Dan Brown36649a618858
diff --git a/app/App/Providers/ThemeServiceProvider.php b/app/App/Providers/ThemeServiceProvider.php
index 2cf581d38..a806c1df6 100644
--- a/app/App/Providers/ThemeServiceProvider.php
+++ b/app/App/Providers/ThemeServiceProvider.php
@@ -24,6 +24,7 @@ class ThemeServiceProvider extends ServiceProvider
{
// Boot up the theme system
$themeService = $this->app->make(ThemeService::class);
+ $themeService->registerViewPathsForTheme($this->app->make('view')->getFinder());
$themeService->readThemeActions();
$themeService->dispatch(ThemeEvents::APP_BOOT, $this->app);
}
diff --git a/app/Config/view.php b/app/Config/view.php
index 80bc9ef8f..2eb30b4c9 100644
--- a/app/Config/view.php
+++ b/app/Config/view.php
@@ -8,12 +8,6 @@
* Do not edit this file unless you're happy to maintain any changes yourself.
*/
-// Join up possible view locations
-$viewPaths = [realpath(base_path('resources/views'))];
-if ($theme = env('APP_THEME', false)) {
- array_unshift($viewPaths, base_path('themes/' . $theme));
-}
-
return [
// App theme
@@ -26,7 +20,7 @@ return [
// Most templating systems load templates from disk. Here you may specify
// an array of paths that should be checked for your views. Of course
// the usual Laravel view path has already been registered for you.
- 'paths' => $viewPaths,
+ 'paths' => [realpath(base_path('resources/views'))],
// Compiled View Path
// This option determines where all the compiled Blade templates will be
diff --git a/app/Theming/ThemeService.php b/app/Theming/ThemeService.php
index 4bdb6836b..87811f0ef 100644
--- a/app/Theming/ThemeService.php
+++ b/app/Theming/ThemeService.php
@@ -6,6 +6,7 @@ use BookStack\Access\SocialDriverManager;
use BookStack\Exceptions\ThemeException;
use Illuminate\Console\Application;
use Illuminate\Console\Application as Artisan;
+use Illuminate\View\FileViewFinder;
use Symfony\Component\Console\Command\Command;
class ThemeService
@@ -90,6 +91,15 @@ class ThemeService
}
}
+ /**
+ * Register any extra paths for where we may expect views to be located
+ * with the provided FileViewFinder, to make custom views available for use.
+ */
+ public function registerViewPathsForTheme(FileViewFinder $finder): void
+ {
+ $finder->prependLocation(theme_path());
+ }
+
/**
* @see SocialDriverManager::addSocialDriver
*/