public function parseResponse() { parent::parseResponse(); if (!$this->wasSuccessful()) { return; } $hits = $this->parsedData->hits->hit; if (0 === count($hits)) { $this->hits = null; return; } $returnHits = array(); foreach ($hits as $hit) { if (isset($hit->data)) { $returnHits[$hit->id] = $hit->data; } else { $returnHits[$hit->id] = $hit->id; } } foreach ($returnHits as $key => $hit) { if (is_object($hit)) { foreach ($hit as $dataKey => $data) { $returnHits[$key]->{$dataKey} = !empty($data) ? $data[0] : null; } } } $this->hits = $returnHits; }
public function parseResponse() { parent::parseResponse(); if (!$this->wasSuccessful()) { return; } $hits = $this->parsedData->hits->hit; $this->props = $this->parsedData->hits; if (isset($this->parsedData->hits->cursor)) { $this->cursor = $this->parsedData->hits->cursor; } if (isset($this->parsedData->facets)) { $this->facets = $this->parsedData->facets; } if (0 === count($hits)) { $this->hits = null; return; } /* Not sure what this is supposed to do * $returnHits = array(); foreach ($hits as $hit) { if (isset($hit->data)) { $returnHits[$hit->id] = $hit->data; } else { $returnHits[$hit->id] = $hit->id; } } foreach ($returnHits as $key => $hit) { if (is_object($hit)) { foreach ($hit as $dataKey => $data) { $returnHits[$key]->{$dataKey} = (!empty($data) ? $data[0] : null); } } } $this->hits = $returnHits; */ $this->hits = $hits; }
/** * Parse the response from AWS */ public function parseResponse() { parent::parseResponse(); if (!$this->wasSuccessful()) { return; } // Get actual suggestions as an array $suggestions = $this->parsedData->suggest->suggestions; if (0 === count($suggestions)) { // No suggestions... $this->suggestions = null; return; } /* $returnSuggestions = array(); foreach ($suggestions as $suggestion) { if (isset($suggestion->suggestion)) { $returnSuggestions[$suggestion->id] = $suggestion->suggestion; } } */ $this->suggestions = $suggestions; }