You are here

protected function MatcherDumper::ensureTableExists in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Routing/MatcherDumper.php \Drupal\Core\Routing\MatcherDumper::ensureTableExists()
  2. 9 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.

File

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

Class

MatcherDumper
Dumps Route information to a database table.

Namespace

Drupal\Core\Routing

Code

protected function ensureTableExists() {
  try {
    $this->connection
      ->schema()
      ->createTable($this->tableName, $this
      ->schemaDefinition());
  } 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.
  } catch (\Exception $e) {
    return FALSE;
  }
  return TRUE;
}