public function AcquiaPurgeQueueStatusTrait::setStatusContext in Acquia Purge 7
1 call to AcquiaPurgeQueueStatusTrait::setStatusContext()
- AcquiaPurgeInvalidation::setStatusContext in lib/
invalidation/ AcquiaPurgeInvalidation.php - Since queue items hold multiple invalidations, the context is kept local.
File
- lib/
queue/ AcquiaPurgeQueueStatusTrait.php, line 102
Class
- AcquiaPurgeQueueStatusTrait
- Provides methods capable of letting multiple actors set a SUCCEEDED or FAILED status, which can then be evaluated to a single overall outcome.
Code
public function setStatusContext($id) {
$new_is_string = is_string($id);
$new_is_null = is_null($id);
if ($new_is_string && !strlen($id)) {
throw new \LogicException('Parameter $id is empty!');
}
elseif (!$new_is_string && !$new_is_null) {
throw new \LogicException('Parameter $id is not NULL or a non-empty string!');
}
elseif ($id === $this->context) {
return;
}
// Find out if statuses returning from executors are actually valid.
$old_is_string = is_string($this->context);
$both_strings = $old_is_string && $new_is_string;
$transferring = $both_strings && $this->context != $id;
if ($transferring || $old_is_string && $new_is_null) {
if (!in_array($this
->getStatus(), $this->statuses_after_processing)) {
throw new LogicException("Executor didn't call ::setStatusFailed() or ::setStatusSucceeded()!");
}
}
$this->context = $id;
}