You are here

public function ResponseParser::parse in Search API Solr 8.3

Same name and namespace in other branches
  1. 8 src/Solarium/Autocomplete/ResponseParser.php \Drupal\search_api_solr\Solarium\Autocomplete\ResponseParser::parse()
  2. 8.2 src/Solarium/Autocomplete/ResponseParser.php \Drupal\search_api_solr\Solarium\Autocomplete\ResponseParser::parse()
  3. 4.x src/Solarium/Autocomplete/ResponseParser.php \Drupal\search_api_solr\Solarium\Autocomplete\ResponseParser::parse()

File

src/Solarium/Autocomplete/ResponseParser.php, line 17

Class

ResponseParser
Autocomplete response parser.

Namespace

Drupal\search_api_solr\Solarium\Autocomplete

Code

public function parse(ResultInterface $result) : array {
  $data = $result
    ->getData();

  /** @var Query $query */
  $query = $result
    ->getQuery();
  $components = [];
  foreach ($query
    ->getComponents() as $component) {
    $componentParser = $component
      ->getResponseParser();
    if ($componentParser) {
      $components[$component
        ->getType()] = $componentParser
        ->parse($query, $component, $data);
    }
  }
  return $this
    ->addHeaderInfo($data, [
    'components' => $components,
  ]);
}