You are here

public function SearchApiTerm::title in Search API 8

Get the title this argument will assign the view, given the argument.

This usually needs to be overridden to provide a proper title.

Overrides ArgumentPluginBase::title

File

src/Plugin/views/argument/SearchApiTerm.php, line 102

Class

SearchApiTerm
Defines a contextual filter searching through all indexed taxonomy fields.

Namespace

Drupal\search_api\Plugin\views\argument

Code

public function title() {
  if (!empty($this->argument)) {
    $this
      ->fillValue();
    $terms = [];
    foreach ($this->value as $tid) {
      $taxonomy_term = $this
        ->getTermStorage()
        ->load($tid);
      if ($taxonomy_term) {
        $terms[] = $this
          ->getEntityRepository()
          ->getTranslationFromContext($taxonomy_term)
          ->label();
      }
    }
    return $terms ? implode(', ', $terms) : $this->argument;
  }
  else {
    return $this->argument;
  }
}