public function QueueService::handleResults in Purge 8.3
Handle processing results and either release back, or delete objects.
Parameters
\Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface[] $invalidations: The invalidation objects after processing.
Overrides QueueServiceInterface::handleResults
See also
\Drupal\purge\Plugin\Purge\Purger\PurgersService::invalidate
File
- src/
Plugin/ Purge/ Queue/ QueueService.php, line 422
Class
- QueueService
- Provides the service that lets invalidations interact with a queue backend.
Namespace
Drupal\purge\Plugin\Purge\QueueCode
public function handleResults(array $invalidations) {
$counters = [
'succeeded' => 0,
'failed' => 0,
'new' => 0,
];
foreach ($invalidations as $invalidation) {
// Although PurgersServiceInterface::invalidate() always resets context
// after purging, we cannot rely on what happened in between. By making
// sure its reset, we know we will always get the general state below.
$invalidation
->setStateContext(NULL);
// Mark succeeded objects as deleting in the buffer.
if ($invalidation
->getState() === InvalidationInterface::SUCCEEDED) {
$this->buffer
->set($invalidation, TxBuffer::DELETING);
$counters['succeeded']++;
}
else {
if (!$this->buffer
->has($invalidation)) {
$this->buffer
->set($invalidation, TxBuffer::ADDING);
$counters['new']++;
}
else {
$this->buffer
->set($invalidation, TxBuffer::RELEASING);
$counters['failed']++;
}
}
}
// Log what happened (but only if info logging is enabled).
if ($this->logger
->isDebuggingEnabled()) {
$this->logger
->debug("handled @no returned items: @results", [
'@no' => count($invalidations),
'@results' => json_encode($counters),
]);
}
}