Skip to content

Commit 36649a6

Browse files
committed
Theme: Updated view registration to be dynamic
Within the responsibility of the theme service instead of being part of the app configuration.
1 parent ff59bbd commit 36649a6

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

app/App/Providers/ThemeServiceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function boot(): void
2424
{
2525
// Boot up the theme system
2626
$themeService = $this->app->make(ThemeService::class);
27+
$themeService->registerViewPathsForTheme($this->app->make('view')->getFinder());
2728
$themeService->readThemeActions();
2829
$themeService->dispatch(ThemeEvents::APP_BOOT, $this->app);
2930
}

app/Config/view.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@
88
* Do not edit this file unless you're happy to maintain any changes yourself.
99
*/
1010

11-
// Join up possible view locations
12-
$viewPaths = [realpath(base_path('resources/views'))];
13-
if ($theme = env('APP_THEME', false)) {
14-
array_unshift($viewPaths, base_path('themes/' . $theme));
15-
}
16-
1711
return [
1812

1913
// App theme
@@ -26,7 +20,7 @@
2620
// Most templating systems load templates from disk. Here you may specify
2721
// an array of paths that should be checked for your views. Of course
2822
// the usual Laravel view path has already been registered for you.
29-
'paths' => $viewPaths,
23+
'paths' => [realpath(base_path('resources/views'))],
3024

3125
// Compiled View Path
3226
// This option determines where all the compiled Blade templates will be

app/Theming/ThemeService.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use BookStack\Exceptions\ThemeException;
77
use Illuminate\Console\Application;
88
use Illuminate\Console\Application as Artisan;
9+
use Illuminate\View\FileViewFinder;
910
use Symfony\Component\Console\Command\Command;
1011

1112
class ThemeService
@@ -90,6 +91,15 @@ public function readThemeActions(): void
9091
}
9192
}
9293

94+
/**
95+
* Register any extra paths for where we may expect views to be located
96+
* with the provided FileViewFinder, to make custom views available for use.
97+
*/
98+
public function registerViewPathsForTheme(FileViewFinder $finder): void
99+
{
100+
$finder->prependLocation(theme_path());
101+
}
102+
93103
/**
94104
* @see SocialDriverManager::addSocialDriver
95105
*/

0 commit comments

Comments
 (0)