function SearchHelpSearch::ensureTableExists

Same name and namespace in other branches
  1. main core/modules/search/modules/search_help/src/Plugin/Search/SearchHelpSearch.php \Drupal\search_help\Plugin\Search\SearchHelpSearch::ensureTableExists()

Check if the help_search_items table exists and create it if not.

File

core/modules/search/modules/search_help/src/Plugin/Search/SearchHelpSearch.php, line 479

Class

SearchHelpSearch
Handles searching for help using the Search module index.

Namespace

Drupal\search_help\Plugin\Search

Code

protected function ensureTableExists() : bool {
  try {
    $database_schema = $this->database
      ->schema();
    if (!$database_schema->tableExists('help_search_items')) {
      $schema_definition = $this->schemaDefinition();
      $database_schema->createTable('help_search_items', $schema_definition);
      return TRUE;
    }
  } catch (DatabaseException) {
    return TRUE;
  }
  return FALSE;
}

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