本文整理汇总了PHP中AbstractResponse::parseResponse方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractResponse::parseResponse方法的具体用法?PHP AbstractResponse::parseResponse怎么用?PHP AbstractResponse::parseResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AbstractResponse
的用法示例。
在下文中一共展示了AbstractResponse::parseResponse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseResponse
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;
}
示例2: parseResponse
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;
}
示例3: parseResponse
/**
* 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;
}