You are here

public function Facet::setResults in Facets 8

Sets the results for the facet.

Parameters

\Drupal\facets\Result\ResultInterface[] $results: The results of the facet.

Overrides FacetInterface::setResults

File

src/Entity/Facet.php, line 785

Class

Facet
Defines the facet configuration entity.

Namespace

Drupal\facets\Entity

Code

public function setResults(array $results) {
  $this->results = $results;

  // If there are active values,
  // set the results which are active to active.
  if (count($this->active_values)) {
    foreach ($this->results as $result) {
      if (in_array($result
        ->getRawValue(), $this->active_values)) {
        $result
          ->setActiveState(TRUE);
      }
    }
  }
}