public function StatsTracker::updateTotals in Purge 8.3
Automatically update the total counters for the given invalidations.
Parameters
\Drupal\purge\Plugin\Purge\Invalidation\InvalidationInterface[] $invalidations: A non-associative array with invalidation objects regardless of the state they're in. Their state will determine which counter will be updated.
Overrides StatsTrackerInterface::updateTotals
File
- src/
Plugin/ Purge/ Queue/ StatsTracker.php, line 185
Class
- StatsTracker
- Provides the queue statistics tracker.
Namespace
Drupal\purge\Plugin\Purge\QueueCode
public function updateTotals(array $invalidations) {
$changes = [
'totalProcessing' => 0,
'totalSucceeded' => 0,
'totalFailed' => 0,
'totalNotSupported' => 0,
];
foreach ($invalidations as $invalidation) {
if ($invalidation
->getState() === InvStatesInterface::PROCESSING) {
$changes['totalProcessing']++;
}
elseif ($invalidation
->getState() === InvStatesInterface::SUCCEEDED) {
$changes['totalSucceeded']++;
}
elseif ($invalidation
->getState() === InvStatesInterface::FAILED) {
$changes['totalFailed']++;
}
elseif ($invalidation
->getState() === InvStatesInterface::NOT_SUPPORTED) {
$changes['totalNotSupported']++;
}
}
foreach ($changes as $stat => $value) {
if ($value === 0) {
continue;
}
elseif ($value > 0) {
$this
->{$stat}()
->increment($value);
}
elseif ($value < 0) {
$this
->{$stat}()
->decrement(abs($value));
}
}
}