You are here

public function GranularItemProcessor::build in Facets 8

Runs before the renderable array is created.

Parameters

\Drupal\facets\FacetInterface $facet: The facet being changed.

\Drupal\facets\Result\ResultInterface[] $results: The results being changed.

Return value

\Drupal\facets\Result\ResultInterface[] The changed results.

Overrides BuildProcessorInterface::build

File

src/Plugin/facets/processor/GranularItemProcessor.php, line 27

Class

GranularItemProcessor
Provides a processor for granularity.

Namespace

Drupal\facets\Plugin\facets\processor

Code

public function build(FacetInterface $facet, array $results) {

  /** @var \Drupal\facets\Result\ResultInterface $result */
  foreach ($results as $result) {
    $value = $result
      ->getRawValue();
    if (is_numeric($value)) {
      $result
        ->setDisplayValue((int) $value . ' - ' . ((int) $value + $this
        ->getConfiguration()['granularity']));
    }
  }
  return $results;
}