You are here

protected function DatabaseBackend::ensureTableExists in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Flood/DatabaseBackend.php \Drupal\Core\Flood\DatabaseBackend::ensureTableExists()

Check if the flood table exists and create it if not.

1 call to DatabaseBackend::ensureTableExists()
DatabaseBackend::register in core/lib/Drupal/Core/Flood/DatabaseBackend.php
Registers an event for the current visitor to the flood control mechanism.

File

core/lib/Drupal/Core/Flood/DatabaseBackend.php, line 150

Class

DatabaseBackend
Defines the database flood backend. This is the default Drupal backend.

Namespace

Drupal\Core\Flood

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;
}