You are here

public function MongoBatchBackend::create in MongoDB 8

Creates and saves a batch.

Parameters

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

Overrides BatchStorageInterface::create

File

src/MongoBatchBackend.php, line 67
Contains \Drupal\mongodb\MongoBatchBackend.

Class

MongoBatchBackend

Namespace

Drupal\mongodb

Code

public function create(array $batch) {

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