Пример #1
0
 /**
  * Get Solr response data.
  *
  * Includes a lazy loading mechanism: JSON body data is decoded on first use and then saved for reuse.
  *
  * @throws UnexpectedValueException
  * @throws RuntimeException
  *
  * @return array
  */
 public function getData()
 {
     if (null === $this->data) {
         switch ($this->query->getResponseWriter()) {
             case AbstractQuery::WT_PHPS:
                 $this->data = unserialize($this->response->getBody());
                 break;
             case AbstractQuery::WT_JSON:
                 $this->data = json_decode($this->response->getBody(), true);
                 break;
             default:
                 throw new RuntimeException('Responseparser cannot handle ' . $this->query->getResponseWriter());
         }
         if (null === $this->data) {
             throw new UnexpectedValueException('Solr JSON response could not be decoded');
         }
     }
     return $this->data;
 }