You are here

protected function BatchStorage::ensureTableExists in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Batch/BatchStorage.php \Drupal\Core\Batch\BatchStorage::ensureTableExists()
  2. 10 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::create in core/lib/Drupal/Core/Batch/BatchStorage.php
Creates and saves a batch.

File

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

Class

BatchStorage

Namespace

Drupal\Core\Batch

Code

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