1 config.inc public ConfigDatabaseStorage::initializeStorage()

Create the database table if does not already exist.

Return value

bool: TRUE on success, FALSE in case of an error.

Throws

ConfigStorageException

Overrides ConfigStorageInterface::initializeStorage

File

core/includes/config.inc, line 1348
This is the API for configuration storage.

Class

ConfigDatabaseStorage
Defines the database storage controller.

Code

public function initializeStorage() {
  // db_table_exists() does not prefix our tables, so we have to do it
  // manually when we do this check.
  $connection_info = Database::getConnectionInfo($this->database);
  $prefix = $connection_info[$this->database]['prefix']['default'];
  if (!db_table_exists($prefix . $this->table)) {
    try {
      db_create_table($this->table, $this->schema($this->table));
    }
    catch (\Exception $e) {
      throw new ConfigStorageException(format_string('The database table %table could not be created: @error', array(
        '%table' => $this->table,
        '@error' => $e->getMessage(),
      )), 0, $e);
    }
  }
  return TRUE;
}