You are here

protected function Parser::parseResultEntries in Google Search Appliance 8

Parse results from the payload.

Parameters

\SimpleXMLElement $payload: Payload.

\Drupal\google_appliance\SearchResults\ResultSet $response: Response.

1 call to Parser::parseResultEntries()
Parser::parseResponse in src/Service/Parser.php
Parses response from GSA.

File

src/Service/Parser.php, line 144

Class

Parser
Defines a class for parsing GSA responses.

Namespace

Drupal\google_appliance\Service

Code

protected function parseResultEntries(SimpleXMLElement $payload, ResultSet $response) {
  foreach ($payload
    ->xpath('//R') as $res) {
    $result = new Result((string) $res->U, (string) $res->UE, (string) $res->T, (string) $res->S, (string) $res->FS['VALUE'], (string) $res['MIME'], isset($res['L']) ? (int) $res['L'] : 1);

    // Result meta data.
    // Here we just collect the data from the device
    // and leave implementing display of meta data
    // to the themer (use-case specific).
    // @see google-appliance-result.tpl.php
    foreach ($res
      ->xpath('./MT') as $mt) {
      $result
        ->addMeta((string) $mt['N'], (string) $mt['V']);
    }
    $response
      ->addResult($result);
  }
}