class AcquiaPurgeQueueItem in Acquia Purge 7
Provides a queue item object.
On the outside, these queue objects are identical in behavior to Drupal's standard DrupalReliableQueueInterface::claimItem() objects and allow read access to its 'item_id', 'created' and 'data' properties.
On top of that however, these objects are capable of letting executor plugins set statuses on them through the ::setStatus() method on the invalidation objects created by ::getInvalidation(). With this, we can easily evaluate the overall outcome at the end and claim or delete it from the queue.
Hierarchy
- class \AcquiaPurgeQueueItem implements AcquiaPurgeQueueItemInterface uses AcquiaPurgeQueueStatusTrait
Expanded class hierarchy of AcquiaPurgeQueueItem
File
- lib/
queue/ AcquiaPurgeQueueItem.php, line 15
View source
class AcquiaPurgeQueueItem implements AcquiaPurgeQueueItemInterface {
use AcquiaPurgeQueueStatusTrait;
/**
* The invalidation class to instantiate invalidation objects from.
*
* @var string
*/
protected $class_invalidation;
/**
* Timestamp when the item was put into the queue.
*
* @var int
* @see AcquiaPurgeQueueInterface::createItem
* @see AcquiaPurgeQueueInterface::claimItem
*/
protected $created;
/**
* Purge specific data to be associated with the new task in the queue.
*
* @var mixed
* @see AcquiaPurgeQueueInterface::createItem
* @see AcquiaPurgeQueueInterface::claimItem
*/
protected $data;
/**
* Timestamp when the item expires from the queue.
*
* @var int
* @see AcquiaPurgeQueueInterface::createItem
* @see AcquiaPurgeQueueInterface::claimItem
*/
protected $expire;
/**
* The unique ID from AcquiaPurgeQueueInterface::createItem().
*
* @var string|int
* @see AcquiaPurgeQueueInterface::createItem
* @see AcquiaPurgeQueueInterface::claimItem
*/
protected $item_id;
/**
* Describes the accessible properties and if they're RO (FALSE) or RW (TRUE).
*
* @var bool[string]
*/
protected $properties = [
'item_id' => TRUE,
'created' => TRUE,
'data' => FALSE,
];
/**
* {@inheritdoc}
*/
public function __construct($created, $data, $expire, $item_id) {
$this->created = $created;
$this->item_id = $item_id;
$this->expire = $expire;
$this->data = $data;
$this->class_invalidation = _acquia_purge_load(array(
'_acquia_purge_invalidation_interface',
'_acquia_purge_invalidation',
));
}
/**
* {@inheritdoc}
*/
public function __get($name) {
if (!isset($this->properties[$name])) {
throw new RuntimeException("The property '{$name}' does not exist.");
}
return $this->{$name};
}
/**
* {@inheritdoc}
*/
public function __set($name, $value) {
if (!isset($this->properties[$name])) {
throw new RuntimeException("The property '{$name}' does not exist.");
}
if (!$this->properties[$name]) {
throw new RuntimeException("The property '{$name}' is read-only.");
}
$this->{$name} = $value;
}
/**
* {@inheritdoc}
*/
public function getInvalidation($scheme, $domain, $base_path) {
return new $this->class_invalidation($scheme, $domain, $base_path, $this);
}
/**
* {@inheritdoc}
*/
public function getPath() {
return $this->data[0];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AcquiaPurgeQueueItem:: |
protected | property | The invalidation class to instantiate invalidation objects from. | |
AcquiaPurgeQueueItem:: |
protected | property | Timestamp when the item was put into the queue. | |
AcquiaPurgeQueueItem:: |
protected | property | Purge specific data to be associated with the new task in the queue. | |
AcquiaPurgeQueueItem:: |
protected | property | Timestamp when the item expires from the queue. | |
AcquiaPurgeQueueItem:: |
protected | property | The unique ID from AcquiaPurgeQueueInterface::createItem(). | |
AcquiaPurgeQueueItem:: |
protected | property | Describes the accessible properties and if they're RO (FALSE) or RW (TRUE). | |
AcquiaPurgeQueueItem:: |
public | function |
Create a invalidation object for the given scheme, domain and base path. Overrides AcquiaPurgeQueueItemInterface:: |
|
AcquiaPurgeQueueItem:: |
public | function |
Get the HTTP path. Overrides AcquiaPurgeQueueItemInterface:: |
|
AcquiaPurgeQueueItem:: |
public | function |
Constructs an queue item object. Overrides AcquiaPurgeQueueItemInterface:: |
|
AcquiaPurgeQueueItem:: |
public | function |
Retrieve a property. Overrides AcquiaPurgeQueueItemInterface:: |
|
AcquiaPurgeQueueItem:: |
public | function |
Set a writable property. Overrides AcquiaPurgeQueueItemInterface:: |
|
AcquiaPurgeQueueStatusInterface:: |
constant | The actor failed processing the item. | ||
AcquiaPurgeQueueStatusInterface:: |
constant | Item is new and no processing has been attempted on it yet. | ||
AcquiaPurgeQueueStatusInterface:: |
constant | The actor succeeded processing the item. | ||
AcquiaPurgeQueueStatusTrait:: |
protected | property | The instance ID of the executor that is about to process this object, or NULL when no longer any executors are processing it. NULL is the default. | |
AcquiaPurgeQueueStatusTrait:: |
protected | property | Associative list in which each key is the context id and the value can be: | |
AcquiaPurgeQueueStatusTrait:: |
protected | property | Statuses in which queue objects can leave processing. Notice that AcquiaPurgeQueueStatusInterface::FRESH is missing, this protects us against badly written executors. | |
AcquiaPurgeQueueStatusTrait:: |
public | function | 1 | |
AcquiaPurgeQueueStatusTrait:: |
public | function | ||
AcquiaPurgeQueueStatusTrait:: |
public | function | ||
AcquiaPurgeQueueStatusTrait:: |
public | function | 1 | |
AcquiaPurgeQueueStatusTrait:: |
public | function | ||
AcquiaPurgeQueueStatusTrait:: |
public | function | ||
AcquiaPurgeQueueStatusTrait:: |
public | function |