Theme: Updated view registration to be dynamic

Within the responsibility of the theme service instead
of being part of the app configuration.
This commit is contained in:
Dan Brown
2026-01-26 11:55:39 +00:00
parent ff59bbdc07
commit 36649a6188
3 changed files with 12 additions and 7 deletions

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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
*/