You are here

class ResponseParser in Search API Solr 8

Same name and namespace in other branches
  1. 8.3 src/Solarium/Autocomplete/ResponseParser.php \Drupal\search_api_solr\Solarium\Autocomplete\ResponseParser
  2. 8.2 src/Solarium/Autocomplete/ResponseParser.php \Drupal\search_api_solr\Solarium\Autocomplete\ResponseParser
  3. 4.x src/Solarium/Autocomplete/ResponseParser.php \Drupal\search_api_solr\Solarium\Autocomplete\ResponseParser

Autocomplete response parser.

Hierarchy

  • class \Drupal\search_api_solr\Solarium\Autocomplete\ResponseParser extends \Solarium\Core\Query\AbstractResponseParser implements \Solarium\Core\Query\ResponseParserInterface

Expanded class hierarchy of ResponseParser

File

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

Namespace

Drupal\search_api_solr\Solarium\Autocomplete
View source
class ResponseParser extends AbstractResponseParser implements ResponseParserInterface {

  /**
   * {@inheritdoc}
   */
  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,
    ]);
  }

}

Members