function MenuTreeStorage::ensureTableExists

Same name in other branches
  1. 9 core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::ensureTableExists()
  2. 8.9.x core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::ensureTableExists()
  3. 10 core/lib/Drupal/Core/Menu/MenuTreeStorage.php \Drupal\Core\Menu\MenuTreeStorage::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 MenuTreeStorage::ensureTableExists()
MenuTreeStorage::safeExecuteSelect in core/lib/Drupal/Core/Menu/MenuTreeStorage.php
Executes a select query while making sure the database table exists.

File

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

Class

MenuTreeStorage
Provides a menu tree storage using the database.

Namespace

Drupal\Core\Menu

Code

protected function ensureTableExists() {
    try {
        $this->connection
            ->schema()
            ->createTable($this->table, static::schemaDefinition());
    } catch (DatabaseException) {
        // 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) {
        return FALSE;
    }
    return TRUE;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.