コード例 #1
0
ファイル: Helper.php プロジェクト: nubs/solarium
 /**
  * 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, ',') . ')';
     }
 }
コード例 #2
0
ファイル: Result.php プロジェクト: lhess/solarium
 /**
  * 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 Query::WT_PHPS:
                 $this->data = unserialize($this->response->getBody());
                 break;
             case Query::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;
 }