Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Remove deprecated API #212

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 14 additions & 88 deletions src/Extension/Engine/SiteTreePublishingEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use SilverStripe\Core\Extension;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Core\Resettable;
use SilverStripe\Dev\Deprecation;
use SilverStripe\ORM\DataObject;
use SilverStripe\StaticPublishQueue\Contract\StaticPublishingTrigger;
use SilverStripe\StaticPublishQueue\Extension\Publishable\PublishableSiteTree;
Expand Down Expand Up @@ -51,88 +50,6 @@ class SiteTreePublishingEngine extends Extension implements Resettable
*/
private array $urlsToDelete = [];

/**
* Queues the urls to be flushed into the queue.
*
* @var array
* @deprecated 6.0.0 Use $urlsToDelete instead
*/
private $toUpdate = [];

/**
* Queues the urls to be deleted as part of a next flush operation.
*
* @var array
* @deprecated 6.0.0 Use $urlsToDelete instead
*/
private $toDelete = [];

/**
* @return array
* @deprecated 6.0.0 Use getUrlsToUpdate() instead
*/
public function getToUpdate()
{
Deprecation::notice('6.0.0', 'Use getUrlsToUpdate() instead');

return $this->toUpdate;
}

/**
* @return array
* @deprecated 6.0.0 Use getUrlsToDelete() instead
*/
public function getToDelete()
{
Deprecation::notice('6.0.0', 'Use getUrlsToDelete() instead');

return $this->toDelete;
}

/**
* @param array $toUpdate
* @return $this
* @deprecated 6.0.0 Use setUrlsToUpdate() instead
*/
public function setToUpdate($toUpdate)
{
Deprecation::notice('6.0.0', 'Use setUrlsToUpdate() instead');

$urlsToUpdate = [];

foreach ($toUpdate as $objectToUpdate) {
$urlsToUpdate = array_merge($urlsToUpdate, array_keys($objectToUpdate->urlsToCache()));
}

$this->setUrlsToUpdate($urlsToUpdate);
// Legacy support so that getToUpdate() still returns the expected array of DataObjects
$this->toUpdate = $toUpdate;

return $this;
}

/**
* @param array $toDelete
* @return $this
* @deprecated 6.0.0 Use setUrlsToDelete() instead
*/
public function setToDelete($toDelete)
{
Deprecation::notice('6.0.0', 'Use setUrlsToUpdate() instead');

$urlsToDelete = [];

foreach ($toDelete as $objectToDelete) {
$urlsToDelete = array_merge($urlsToDelete, array_keys($objectToDelete->urlsToCache()));
}

$this->setUrlsToDelete($urlsToDelete);
// Legacy support so that getToDelete() still returns the expected array of DataObjects
$this->toDelete = $toDelete;

return $this;
}

public static function reset(): void
{
static::$queueService = null;
Expand Down Expand Up @@ -283,11 +200,11 @@ public function collectChanges($context)
return;
}

// Fetch our objects to be actioned
Deprecation::withSuppressedNotice(function () use ($siteTree, $context): void {
$this->setToUpdate($siteTree->objectsToUpdate($context));
$this->setToDelete($siteTree->objectsToDelete($context));
});
// Fetch our URLs to be actioned
$urlsToUpdate = $this->getUrlsFromObjects($siteTree->objectsToUpdate($context));
$this->setUrlsToUpdate($urlsToUpdate);
$urlsToUpdate = $this->getUrlsFromObjects($siteTree->objectsToDelete($context));
$this->setUrlsToDelete($urlsToUpdate);
});
}

Expand Down Expand Up @@ -327,4 +244,13 @@ public function flushChanges()
$this->setUrlsToDelete([]);
}
}

private function getUrlsFromObjects(iterable $objects): iterable
{
$urls = [];
foreach ($objects as $object) {
$urls = array_merge($urls, array_keys($object->urlsToCache()));
}
return $urls;
}
}
Loading