class BatchStorage implements BatchStorageInterface (View source)

Constants

TABLE_NAME

The table name.

Properties

protected Connection $connection

The database connection.

protected SessionInterface $session

The session.

protected CsrfTokenGenerator $csrfToken

The CSRF token generator.

Methods

__construct(Connection $connection, SessionInterface $session, CsrfTokenGenerator $csrf_token)

Constructs the database batch storage service.

array
load(int $id)

Loads a batch.

delete(int $id)

Deletes a batch.

update(array $batch)

Updates a batch.

cleanup()

Cleans up failed or old batches.

create(array $batch)

Creates and saves a batch.

doCreate(array $batch)

Saves a batch.

ensureTableExists()

Check if the table exists and create it if not.

catchException(Exception $e)

Act on an exception when batch might be stale.

schemaDefinition()

Defines the schema for the batch table.

Details

__construct(Connection $connection, SessionInterface $session, CsrfTokenGenerator $csrf_token)

Constructs the database batch storage service.

Parameters

Connection $connection

The database connection.

SessionInterface $session

The session.

CsrfTokenGenerator $csrf_token

The CSRF token generator.

array load(int $id)

Loads a batch.

Parameters

int $id

The ID of the batch to load.

Return Value

array

An array representing the batch, or FALSE if no batch was found.

delete(int $id)

Deletes a batch.

Parameters

int $id

The ID of the batch to delete.

update(array $batch)

Updates a batch.

Parameters

array $batch

The array representing the batch to update.

cleanup()

Cleans up failed or old batches.

create(array $batch)

Creates and saves a batch.

Parameters

array $batch

The array representing the batch to create.

protected doCreate(array $batch)

Saves a batch.

Parameters

array $batch

The array representing the batch to create.

protected ensureTableExists()

Check if the table exists and create it if not.

protected catchException(Exception $e)

Act on an exception when batch might be stale.

If the table does not yet exist, that's fine, but if the table exists and yet the query failed, then the batch is stale and the exception needs to propagate.

Parameters

Exception $e

The exception.

Exceptions

Exception

schemaDefinition()

internal  
 

Defines the schema for the batch table.