function BatchStorage::create

Creates and saves a batch.

Parameters

array $batch: The array representing the batch to create.

Overrides BatchStorageInterface::create

File

core/lib/Drupal/Core/Batch/BatchStorage.php, line 136

Class

BatchStorage

Namespace

Drupal\Core\Batch

Code

public function create(array $batch) {
  // Ensure that a session is started before using the CSRF token generator,
  // and update the database record.
  $this->session
    ->start();
  $this->connection
    ->update('batch')
    ->fields([
    'token' => $this->csrfToken
      ->get($batch['id']),
    'batch' => serialize($batch),
  ])
    ->condition('bid', $batch['id'])
    ->execute();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.