protected function DatabaseStorage::ensureTableExists
protected DatabaseStorage::ensureTableExists()
Check if the config table exists and create it if not.
Return value
bool TRUE if the table was created, FALSE otherwise.
Throws
\Drupal\Core\Config\StorageException If a database error occurs.
File
- core/lib/Drupal/Core/Config/DatabaseStorage.php, line 162
Class
- DatabaseStorage
- Defines the Database storage.
Namespace
Drupal\Core\ConfigCode
protected function ensureTableExists() { try { if (!$this->connection->schema()->tableExists($this->table)) { $this->connection->schema()->createTable($this->table, static::schemaDefinition()); return TRUE; } } // 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 (SchemaObjectExistsException $e) { return TRUE; } catch (\Exception $e) { throw new StorageException($e->getMessage(), NULL, $e); } 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!Config!DatabaseStorage.php/function/DatabaseStorage::ensureTableExists/8.1.x