Skip to content

Commit

Permalink
Merge pull request #192 from creative-commoners/pulls/6.2/remove-self
Browse files Browse the repository at this point in the history
ENH Use class name instead of self
  • Loading branch information
GuySartorelli authored Jun 17, 2024
2 parents c79046c + ade614c commit 5060c27
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/Extension/Engine/SiteTreePublishingEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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);
Expand Down Expand Up @@ -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();

Expand Down
16 changes: 8 additions & 8 deletions src/Extension/Publishable/PublishableSiteTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Publisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = static::config()->get('static_publisher_themes');
if ($staticThemes) {
SSViewer::set_themes($staticThemes);
} else {
Expand Down
2 changes: 1 addition & 1 deletion tests/php/QueuedJobsTestService.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function queueJob(QueuedJob $job, $startAfter = null, $userId = null, $qu

public static function reset()
{
self::singleton()->flushJobs();
QueuedJobsTestService::singleton()->flushJobs();
}

/**
Expand Down

0 comments on commit 5060c27

Please sign in to comment.