You are here

public function BatchBuilder::setQueue in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Batch/BatchBuilder.php \Drupal\Core\Batch\BatchBuilder::setQueue()
  2. 9 core/lib/Drupal/Core/Batch/BatchBuilder.php \Drupal\Core\Batch\BatchBuilder::setQueue()

Sets an override for the default queue.

The class will typically either be \Drupal\Core\Queue\Batch or \Drupal\Core\Queue\BatchMemory. The class defaults to Batch if progressive is TRUE, or to BatchMemory if progressive is FALSE.

Parameters

string $name: The unique identifier for the queue.

string $class: The fully qualified name of a class that implements \Drupal\Core\Queue\QueueInterface.

Return value

$this

File

core/lib/Drupal/Core/Batch/BatchBuilder.php, line 287

Class

BatchBuilder
Builds an array for a batch process.

Namespace

Drupal\Core\Batch

Code

public function setQueue($name, $class) {
  if (!class_exists($class)) {
    throw new \InvalidArgumentException('Class ' . $class . ' does not exist.');
  }
  if (!in_array(QueueInterface::class, class_implements($class))) {
    throw new \InvalidArgumentException('Class ' . $class . ' does not implement \\Drupal\\Core\\Queue\\QueueInterface.');
  }
  $this->queue = [
    'name' => $name,
    'class' => $class,
  ];
  return $this;
}