Theme System: Fixed theme view before/after issues

- Updated the system to work with modules.
- Updated module docs to consider namespacing.
- Fixed view loading and registration event ordering.
- Fixed checking if views are registered.
This commit is contained in:
Dan Brown
2026-02-07 23:01:13 +00:00
parent 9d3d0a4a07
commit a20438b901
4 changed files with 34 additions and 11 deletions

View File

@@ -5,7 +5,7 @@ namespace Tests\Theme;
use BookStack\Facades\Theme;
use Tests\TestCase;
class ThemeModuleTests extends TestCase
class ThemeModuleTest extends TestCase
{
public function test_modules_loaded_on_theme_load()
{
@@ -207,6 +207,19 @@ class ThemeModuleTests extends TestCase
});
}
public function test_module_can_use_theme_view_render_functions()
{
$this->usingModuleFolder(function (string $moduleFolderPath) {
file_put_contents($moduleFolderPath . '/functions.php', "<?php\n\BookStack\Facades\Theme::listen(\BookStack\Theming\ThemeEvents::THEME_REGISTER_VIEWS, fn(\$views) => \$views->renderBefore('layouts.parts.header', 'cat', 100));");
mkdir($moduleFolderPath . '/views', 0777, true);
file_put_contents($moduleFolderPath . '/views/cat.blade.php', 'mysupercatispouncy');
$this->refreshApplication();
$this->asAdmin()->get('/')->assertSee('mysupercatispouncy');
});
}
protected function usingModuleFolder(callable $callback): void
{
$this->usingThemeFolder(function (string $themeFolder) use ($callback) {