/** * Processes the raw results from a QBank search and creates a {@link SearchResult}. * @param stdClass $result * @param bool $advanced Whether to populate the SearchResult with Advanced objects. * @author Björn Hjortsten * @return SearchResult */ protected function processResult($result, $advanced = false) { if (is_array($result->data->searchResults) && !empty($result->data->searchResults)) { foreach ($result->data->searchResults as $rawObject) { $objects[] = SimpleObject::createFromRawObject($rawObject); } if ($advanced === true) { foreach ($objects as $key => $object) { $calls[] = array('name' => $key, 'function' => 'getobjectinformation', 'arguments' => array('objectId' => $object->getId())); } $result2 = $this->call('batch', array('calls' => $calls), true); $objects = array(); foreach ($result2->results as $res) { $objects[] = Object::createFromRawObject($res->data); } } } else { $objects = array(); } $searchResult = new SearchResult($objects, intval($result->data->counter), $result->data->timeSearching, $result->data->step, $result->data->timeStamp, $result->data->end); return $searchResult; }
/** * Gets an object from QBank * @param int $id The id of the object. * @throws CommunicationException Thrown if something went wrong while getting the object. * @throws ConnectionException Thrown if something went wrong with the connection. * @author Björn Hjortsten * @return Object */ public function getObject($id) { $result = $this->call('getobjectinformation', array('objectId' => $id)); return Object::createFromRawObject($result->data); }