Esempio n. 1
0
 /**
  * Render a functionCall.
  *
  * @param string  $name
  * @param array   $params
  * @param boolean $dereferenced
  *
  * @return string
  */
 public function functionCall($name, $params = array(), $dereferenced = false)
 {
     if ($dereferenced) {
         foreach ($params as $key => $value) {
             $this->query->addParam($key, $value);
         }
         return $name . '()';
     } else {
         return $name . '(' . implode($params, ',') . ')';
     }
 }
Esempio n. 2
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;
 }