You are here

public function Database::viewSettings in Search API 8

Returns additional, backend-specific information about this server.

This information will be then added to the server's "View" tab in some way. In the default theme implementation the data is output in a table with two columns along with other, generic information about the server.

Return value

array An array of additional server information, with each piece of information being an associative array with the following keys:

  • label: The human-readable label for this data.
  • info: The information, as HTML.
  • status: (optional) The status associated with this information. One of "info", "ok", "warning" or "error". Defaults to "info".

Overrides BackendPluginBase::viewSettings

File

modules/search_api_db/src/Plugin/search_api/backend/Database.php, line 540

Class

Database
Indexes and searches items using the database.

Namespace

Drupal\search_api_db\Plugin\search_api\backend

Code

public function viewSettings() {
  $info = [];
  $info[] = [
    'label' => $this
      ->t('Database'),
    'info' => str_replace(':', ' > ', $this->configuration['database']),
  ];
  if ($this->configuration['min_chars'] > 1) {
    $info[] = [
      'label' => $this
        ->t('Minimum word length'),
      'info' => $this->configuration['min_chars'],
    ];
  }
  $labels = [
    'words' => $this
      ->t('Match whole words only'),
    'partial' => $this
      ->t('Match on parts of a word'),
    'prefix' => $this
      ->t('Match words starting with given keywords'),
  ];
  $info[] = [
    'label' => $this
      ->t('Partial matching'),
    'info' => $labels[$this->configuration['matching']],
  ];
  if (!empty($this->configuration['autocomplete'])) {
    $this->configuration['autocomplete'] += [
      'suggest_suffix' => TRUE,
      'suggest_words' => TRUE,
    ];
    $autocomplete_modes = [];
    if ($this->configuration['autocomplete']['suggest_suffix']) {
      $autocomplete_modes[] = $this
        ->t('Suggest word endings');
    }
    if ($this->configuration['autocomplete']['suggest_words']) {
      $autocomplete_modes[] = $this
        ->t('Suggest additional words');
    }
    $autocomplete_modes = $autocomplete_modes ? implode('; ', $autocomplete_modes) : $this
      ->t('none');
    $info[] = [
      'label' => $this
        ->t('Autocomplete suggestions'),
      'info' => $autocomplete_modes,
    ];
  }
  return $info;
}