You are here

public function BatchStorage::create in Zircon Profile 8

Same name in this branch
  1. 8 core/lib/Drupal/Core/Batch/BatchStorage.php \Drupal\Core\Batch\BatchStorage::create()
  2. 8 core/lib/Drupal/Core/ProxyClass/Batch/BatchStorage.php \Drupal\Core\ProxyClass\Batch\BatchStorage::create()
Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Batch/BatchStorage.php \Drupal\Core\Batch\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 101
Contains \Drupal\Core\Batch\BatchStorage.

Class

BatchStorage

Namespace

Drupal\Core\Batch

Code

public function create(array $batch) {

  // Ensure that a session is started before using the CSRF token generator.
  $this->session
    ->start();
  $this->connection
    ->insert('batch')
    ->fields(array(
    'bid' => $batch['id'],
    'timestamp' => REQUEST_TIME,
    'token' => $this->csrfToken
      ->get($batch['id']),
    'batch' => serialize($batch),
  ))
    ->execute();
}