From be29067208a9f88267e80d51211c391894941606 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Wed, 5 Jun 2024 16:35:34 +1200 Subject: [PATCH] ENH Use class name instead of self --- .../Engine/SiteTreePublishingEngine.php | 8 ++++---- .../Publishable/PublishableSiteTree.php | 16 ++++++++-------- src/Publisher.php | 2 +- tests/php/QueuedJobsTestService.php | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Extension/Engine/SiteTreePublishingEngine.php b/src/Extension/Engine/SiteTreePublishingEngine.php index 582906b9..b566d566 100644 --- a/src/Extension/Engine/SiteTreePublishingEngine.php +++ b/src/Extension/Engine/SiteTreePublishingEngine.php @@ -189,7 +189,7 @@ public function onBeforePublishRecursive($original) ) { // We have detected a change to the URL. We need to purge the old URLs for this page and any children $context = [ - 'action' => self::ACTION_UNPUBLISH, + 'action' => SiteTreePublishingEngine::ACTION_UNPUBLISH, ]; // We'll collect these changes now (before the URLs change), but they won't be actioned until the publish // action has completed successfully, and onAfterPublishRecursive() has been called. This is because we @@ -216,7 +216,7 @@ public function onAfterPublishRecursive($original) $urlSegmentChanged = $urlSegment && $original->URLSegment !== $owner->URLSegment; $context = [ - 'action' => self::ACTION_PUBLISH, + 'action' => SiteTreePublishingEngine::ACTION_PUBLISH, // If a URL change has been detected, then we need to force the recursive regeneration of all child // pages 'urlSegmentChanged' => $parentChanged || $urlSegmentChanged, @@ -231,7 +231,7 @@ public function onAfterPublishRecursive($original) public function onBeforeUnpublish() { $context = [ - 'action' => self::ACTION_UNPUBLISH, + 'action' => SiteTreePublishingEngine::ACTION_UNPUBLISH, ]; // We'll collect these changes now, but they won't be actioned until onAfterUnpublish() $this->collectChanges($context); @@ -266,7 +266,7 @@ public function collectChanges($context) // This is purely because if a page has an unpublished parent, then the LIVE URL will be incorrect (it will // be missing the parent slug) - we'd prefer to cache to correct URL (with parentage) even though it'll be // a cache of a 404 - Versioned::set_stage($action === self::ACTION_UNPUBLISH ? Versioned::LIVE: Versioned::DRAFT); + Versioned::set_stage($action === SiteTreePublishingEngine::ACTION_UNPUBLISH ? Versioned::LIVE: Versioned::DRAFT); $owner = $this->getOwner(); diff --git a/src/Extension/Publishable/PublishableSiteTree.php b/src/Extension/Publishable/PublishableSiteTree.php index ba44dcf7..394cd1fe 100644 --- a/src/Extension/Publishable/PublishableSiteTree.php +++ b/src/Extension/Publishable/PublishableSiteTree.php @@ -28,9 +28,9 @@ class PublishableSiteTree extends DataExtension implements StaticallyPublishable public const REGENERATE_RELATIONS_DIRECT = 'direct'; public const REGENERATE_RELATIONS_RECURSIVE = 'recursive'; - private static string $regenerate_children = self::REGENERATE_RELATIONS_NONE; + private static string $regenerate_children = PublishableSiteTree::REGENERATE_RELATIONS_NONE; - private static string $regenerate_parents = self::REGENERATE_RELATIONS_DIRECT; + private static string $regenerate_parents = PublishableSiteTree::REGENERATE_RELATIONS_DIRECT; public function getMyVirtualPages() { @@ -66,12 +66,12 @@ public function objectsToUpdate($context) $forceRecursiveRegeneration = $context['urlSegmentChanged'] ?? false; // We've either been configured to regenerate (some level) of children, or the above context has been set - if ($regenerateChildren !== self::REGENERATE_RELATIONS_NONE || $forceRecursiveRegeneration) { + if ($regenerateChildren !== PublishableSiteTree::REGENERATE_RELATIONS_NONE || $forceRecursiveRegeneration) { // We will want to recursively add all children if our regenerate_children config was set to Recursive, // or if $forceRecursiveRegeneration was set to true // If neither of those conditions are true, then we will only be adding the direct children of this // parent page - $recursive = $regenerateChildren === self::REGENERATE_RELATIONS_RECURSIVE || $forceRecursiveRegeneration; + $recursive = $regenerateChildren === PublishableSiteTree::REGENERATE_RELATIONS_RECURSIVE || $forceRecursiveRegeneration; $this->addChildren($list, $siteTree, $recursive); } @@ -81,9 +81,9 @@ public function objectsToUpdate($context) // 'none' means that we want to include children at some level $regenerateParents = SiteTree::config()->get('regenerate_parents'); - if ($regenerateParents !== self::REGENERATE_RELATIONS_NONE) { + if ($regenerateParents !== PublishableSiteTree::REGENERATE_RELATIONS_NONE) { // You can also choose whether to update only the direct parent, or the entire tree - $recursive = $regenerateParents === self::REGENERATE_RELATIONS_RECURSIVE; + $recursive = $regenerateParents === PublishableSiteTree::REGENERATE_RELATIONS_RECURSIVE; $this->addParents($list, $siteTree, $recursive); } @@ -128,12 +128,12 @@ public function objectsToDelete($context) $forceRecursiveRegeneration = SiteTree::config()->get('enforce_strict_hierarchy'); // We've either been configured to include (some level) of children, or enforce_strict_hierarchy was true - if ($regenerateChildren !== self::REGENERATE_RELATIONS_NONE || $forceRecursiveRegeneration) { + if ($regenerateChildren !== PublishableSiteTree::REGENERATE_RELATIONS_NONE || $forceRecursiveRegeneration) { // We will want to recursively add all children if our regenerate_children config was set to Recursive, // or if $forceRecursiveRegeneration was set to true // If neither of those conditions are true, then we will only be adding the direct children of this // parent page - $recursive = $regenerateChildren === self::REGENERATE_RELATIONS_RECURSIVE || $forceRecursiveRegeneration; + $recursive = $regenerateChildren === PublishableSiteTree::REGENERATE_RELATIONS_RECURSIVE || $forceRecursiveRegeneration; $this->addChildren($list, $siteTree, $recursive); } diff --git a/src/Publisher.php b/src/Publisher.php index 4a8108f1..aea706cc 100644 --- a/src/Publisher.php +++ b/src/Publisher.php @@ -79,7 +79,7 @@ public function generatePageResponse($url) Requirements::set_backend(Requirements_Backend::create()); $origThemes = SSViewer::get_themes(); - $staticThemes = self::config()->get('static_publisher_themes'); + $staticThemes = Publisher::config()->get('static_publisher_themes'); if ($staticThemes) { SSViewer::set_themes($staticThemes); } else { diff --git a/tests/php/QueuedJobsTestService.php b/tests/php/QueuedJobsTestService.php index f01dd640..46748b5c 100644 --- a/tests/php/QueuedJobsTestService.php +++ b/tests/php/QueuedJobsTestService.php @@ -39,7 +39,7 @@ public function queueJob(QueuedJob $job, $startAfter = null, $userId = null, $qu public static function reset() { - self::singleton()->flushJobs(); + QueuedJobsTestService::singleton()->flushJobs(); } /**