From 50519cd04249e4d023623b820507c1a19a85dcfa Mon Sep 17 00:00:00 2001 From: Mojmir Fendek Date: Fri, 22 Dec 2023 13:27:40 +1300 Subject: [PATCH] NEW: Extension points for FilesystemPublisher. --- src/Publisher.php | 2 ++ src/Publisher/FilesystemPublisher.php | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/Publisher.php b/src/Publisher.php index 06520914..4a8108f1 100644 --- a/src/Publisher.php +++ b/src/Publisher.php @@ -10,6 +10,7 @@ use SilverStripe\Core\Config\Configurable; use SilverStripe\Core\CoreKernel; use SilverStripe\Core\Environment; +use SilverStripe\Core\Extensible; use SilverStripe\Core\Injector\Injectable; use SilverStripe\ORM\DataObject; use SilverStripe\ORM\FieldType\DBDatetime; @@ -22,6 +23,7 @@ abstract class Publisher implements StaticPublisher { + use Extensible; use Injectable; use Configurable; diff --git a/src/Publisher/FilesystemPublisher.php b/src/Publisher/FilesystemPublisher.php index 63e0c49a..2cbab79c 100644 --- a/src/Publisher/FilesystemPublisher.php +++ b/src/Publisher/FilesystemPublisher.php @@ -109,7 +109,11 @@ public function publishURL($url, $forcePublish = false) return; } $success = false; + + $this->extend('onBeforeGeneratePageResponse', $url); $response = $this->generatePageResponse($url); + $this->extend('onAfterGeneratePageResponse', $url, $response); + $statusCode = $response->getStatusCode(); $doPublish = ($forcePublish && $this->getFileExtension() === 'php') || $statusCode < 400;