W3cubDocs

/Drupal 8

function _batch_populate_queue

_batch_populate_queue(&$batch, $set_id)

Populates a job queue with the operations of a batch set.

Depending on whether the batch is progressive or not, the Drupal\Core\Queue\Batch or Drupal\Core\Queue\BatchMemory handler classes will be used. The name and class of the queue are added by reference to the batch set.

Parameters

$batch: The batch array.

$set_id: The id of the set to process.

Related topics

Batch operations
Creates and processes batch operations.

File

core/includes/form.inc, line 902
Functions for form and batch generation and processing.

Code

function _batch_populate_queue(&$batch, $set_id) {
  $batch_set = &$batch['sets'][$set_id];

  if (isset($batch_set['operations'])) {
    $batch_set += array(
      'queue' => array(
        'name' => 'drupal_batch:' . $batch['id'] . ':' . $set_id,
        'class' => $batch['progressive'] ? 'Drupal\Core\Queue\Batch' : 'Drupal\Core\Queue\BatchMemory',
      ),
    );

    $queue = _batch_queue($batch_set);
    $queue->createQueue();
    foreach ($batch_set['operations'] as $operation) {
      $queue->createItem($operation);
    }

    unset($batch_set['operations']);
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!includes!form.inc/function/_batch_populate_queue/8.1.x