Skip to content

Commit

Permalink
Add extension hooks for static file writing
Browse files Browse the repository at this point in the history
Allowing for project level customisation of the environment within which
the static content is obtained before it is written.

For example allowing third party modules to affect whether their
middleware is active or not, which may otherwise prevent accurate
content retrieval.
  • Loading branch information
NightJar committed Oct 22, 2024
1 parent 5510305 commit 648cd87
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ErrorPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ public function writeStaticPage()
// Run the page (reset the theme, it might've been disabled by LeftAndMain::init())
$originalThemes = SSViewer::get_themes();
try {
$this->extend('onBeforeStaticWrite');
// Restore front-end themes from config
$themes = SSViewer::config()->get('themes') ?: $originalThemes;
SSViewer::set_themes($themes);
Expand All @@ -336,6 +337,7 @@ public function writeStaticPage()
} finally {
// Restore themes
SSViewer::set_themes($originalThemes);
$this->extend('onAfterStaticWrite');
}

// Make sure we have content to save
Expand Down

0 comments on commit 648cd87

Please sign in to comment.