MenuTreeStorage::ensureTableExists

protected MenuTreeStorage::ensureTableExists()

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

Return value

bool TRUE if the table was created, FALSE otherwise.

Throws

\Drupal\Component\Plugin\Exception\PluginException If a database error occurs.

File

core/lib/Drupal/Core/Menu/MenuTreeStorage.php, line 1151

Class

MenuTreeStorage
Provides a menu tree storage using the database.

Namespace

Drupal\Core\Menu

Code

protected function ensureTableExists() {
  try {
    if (!$this->connection->schema()->tableExists($this->table)) {
      $this->connection->schema()->createTable($this->table, static::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;
  }
  catch (\Exception $e) {
    throw new PluginException($e->getMessage(), NULL, $e);
  }
  return FALSE;
}
doc_Drupal
2016-10-29 09:27:36
Comments
Leave a Comment

Please login to continue.