Beispiel #1
0
 /**
  * @inheritDoc
  */
 public function search($object, $search, $offset = 0, $limit = 50)
 {
     if (empty($search)) {
         $object .= '?q=all';
     } else {
         $query = '';
         foreach ($search as $key => $val) {
             $query .= 'q[' . urldecode($key) . ']=' . urlencode($val) . '&';
         }
         if ($query == 'q[]=&') {
             $object .= '?q=all';
         } else {
             $object .= '?' . rtrim($query, '&');
         }
     }
     $object .= '&offset=' . $offset . '&limit=' . $limit;
     $response = $this->request('get', $object);
     if ($response->status == 200) {
         $result = new SearchResult($offset, $limit);
         $result->setQuery($response->body->query);
         $result->setNumMatching($response->body->matching);
         $result->setObjects($response->body->objects);
         return $result;
     } else {
         throw new ClientException($this->lastResponse, $response->status);
     }
 }