You are here

protected function ListItemProcessor::overWriteDisplayValues in Facets 8

Overwrite the display value of the result with a new text.

Parameters

\Drupal\facets\Result\ResultInterface[] $results: An array of results to work on.

array $replacements: An array of values that contain possible replacements for the orignal values.

Return value

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

1 call to ListItemProcessor::overWriteDisplayValues()
ListItemProcessor::build in src/Plugin/facets/processor/ListItemProcessor.php
Runs before the renderable array is created.

File

src/Plugin/facets/processor/ListItemProcessor.php, line 182

Class

ListItemProcessor
Provides a processor that transforms the results to show the list item label.

Namespace

Drupal\facets\Plugin\facets\processor

Code

protected function overWriteDisplayValues(array $results, array $replacements) {

  /** @var \Drupal\facets\Result\ResultInterface $a */
  foreach ($results as &$a) {
    if (isset($replacements[$a
      ->getRawValue()])) {
      $a
        ->setDisplayValue($replacements[$a
        ->getRawValue()]);
    }
  }
  return $results;
}