protected function MatcherDumper::ensureTableExists

protected 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 176

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 (SchemaObjectExistsException $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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Routing!MatcherDumper.php/function/MatcherDumper::ensureTableExists/8.1.x