function BatchStorage::ensureTableExists

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Batch/BatchStorage.php \Drupal\Core\Batch\BatchStorage::ensureTableExists()
  2. 8.9.x core/lib/Drupal/Core/Batch/BatchStorage.php \Drupal\Core\Batch\BatchStorage::ensureTableExists()
  3. 11.x core/lib/Drupal/Core/Batch/BatchStorage.php \Drupal\Core\Batch\BatchStorage::ensureTableExists()

Check if the table exists and create it if not.

1 call to BatchStorage::ensureTableExists()
BatchStorage::getId in core/lib/Drupal/Core/Batch/BatchStorage.php
Returns a new batch id.

File

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

Class

BatchStorage

Namespace

Drupal\Core\Batch

Code

protected function ensureTableExists() {
  try {
    $database_schema = $this->connection
      ->schema();
    $schema_definition = $this->schemaDefinition();
    $database_schema->createTable(static::TABLE_NAME, $schema_definition);
  } catch (DatabaseException $e) {
  } catch (\Exception $e) {
    return FALSE;
  }
  return TRUE;
}

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