You are here

public function JsonApiQueryString::setActiveItems in JSON:API Search API 8

Sets active items.

Is called after the url processor is ready retrieving and altering the active filters to let the facet know about the active items.

Parameters

\Drupal\facets\FacetInterface $facet: The facet that is edited.

Overrides UrlProcessorPluginBase::setActiveItems

File

modules/jsonapi_search_api_facets/src/Plugin/facets/url_processor/JsonApiQueryString.php, line 92

Class

JsonApiQueryString
Query string URL processor.

Namespace

Drupal\jsonapi_search_api_facets\Plugin\facets\url_processor

Code

public function setActiveItems(FacetInterface $facet) {

  // Get the filter key of the facet.
  if (isset($this->activeFilters[$facet
    ->id()])) {
    $active_filters = $this->activeFilters[$facet
      ->id()];
    if (is_array($active_filters)) {
      $facet
        ->setActiveItems($active_filters);
    }
    else {
      $facet
        ->setActiveItem($active_filters);
    }
  }
}