You are here

protected function RevisionTracker::ensureTableExists in Workbench Moderation 8

Same name and namespace in other branches
  1. 8.2 src/RevisionTracker.php \Drupal\workbench_moderation\RevisionTracker::ensureTableExists()

Checks if the table exists and create it if not.

Return value

bool TRUE if the table was created, FALSE otherwise.

1 call to RevisionTracker::ensureTableExists()
RevisionTracker::setLatestRevision in src/RevisionTracker.php
Sets the latest revision of a given entity.

File

src/RevisionTracker.php, line 92

Class

RevisionTracker
Tracks metadata about revisions across entities.

Namespace

Drupal\workbench_moderation

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 table, attempting to
    // recreate it will throw an exception. In this case just catch the
    // exception and do nothing.
    return TRUE;
  }
  return FALSE;
}