You are here

protected function MatcherDumper::ensureTableExists in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Routing/MatcherDumper.php \Drupal\Core\Routing\MatcherDumper::ensureTableExists()
  2. 10 core/lib/Drupal/Core/Routing/MatcherDumper.php \Drupal\Core\Routing\MatcherDumper::ensureTableExists()

Checks if the tree table exists and create it if not.

Return value

bool TRUE if the table was created, FALSE otherwise.

1 call to MatcherDumper::ensureTableExists()
MatcherDumper::dump in core/lib/Drupal/Core/Routing/MatcherDumper.php
Dumps a set of routes to the router table in the database.

File

core/lib/Drupal/Core/Routing/MatcherDumper.php, line 175

Class

MatcherDumper
Dumps Route information to a database table.

Namespace

Drupal\Core\Routing

Code

protected function ensureTableExists() {
  try {
    if (!$this->connection
      ->schema()
      ->tableExists($this->tableName)) {
      $this->connection
        ->schema()
        ->createTable($this->tableName, $this
        ->schemaDefinition());
      return TRUE;
    }
  } catch (DatabaseException $e) {

    // If another process has already created the config table, attempting to
    // recreate it will throw an exception. In this case just catch the
    // exception and do nothing.
    return TRUE;
  }
  return FALSE;
}