You are here

class QueueData in Warmer 2.x

Same name and namespace in other branches
  1. 8 src/QueueData.php \Drupal\warmer\QueueData

Value object to store in the queue with all the infor to process a batch.

Hierarchy

Expanded class hierarchy of QueueData

2 files declare their use of QueueData
ItemWarmer.php in src/Plugin/QueueWorker/ItemWarmer.php
ItemWarmerTest.php in tests/src/Unit/Plugin/QueueWorker/ItemWarmerTest.php

File

src/QueueData.php, line 8

Namespace

Drupal\warmer
View source
class QueueData {

  /**
   * The callback to call on dequeue.
   *
   * @var callable
   */
  private $callback;

  /**
   * The item IDs to process.
   *
   * @var array
   */
  private $ids;

  /**
   * The warmer ID.
   *
   * @var string
   */
  private $warmerId;

  /**
   * Creates a queue data object.
   *
   * @param callable $callback
   *   The callback to call on dequeue.
   * @param array $ids
   *   The item IDs to process.
   * @param $warmer_id
   *   The warmer ID.
   */
  public function __construct(callable $callback, array $ids, $warmer_id) {
    $this->callback = $callback;
    $this->ids = $ids;
    $this->warmerId = $warmer_id;
  }

  /**
   * Function to execute after claiming the item.
   */
  public function process() {
    call_user_func($this->callback, $this->ids, $this->warmerId);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
QueueData::$callback private property The callback to call on dequeue.
QueueData::$ids private property The item IDs to process.
QueueData::$warmerId private property The warmer ID.
QueueData::process public function Function to execute after claiming the item.
QueueData::__construct public function Creates a queue data object.