예제 #1
0
 /**
  * Returns core status info.
  *
  * @param string $core Name of the core to return the status for, or null
  *                     to return status for all cores.
  */
 public function status($core = null)
 {
     $query = ["action" => "STATUS", "wt" => "json"];
     if (isset($core)) {
         $query['core'] = $core;
     }
     $path = "admin/cores?" . http_build_query($query);
     $response = $this->get($path);
     $contents = $response->getBody()->getContents();
     return Json::decode($contents, true);
 }
예제 #2
0
 private function importFile(Client $client, $core, SplFileInfo $source, $output)
 {
     $output->writeln("Importing data from: <info>{$source}</info>");
     $fp = fopen($source, 'r');
     $path = "{$core}/update?" . http_build_query(['commit' => 'true', 'wt' => 'json']);
     $headers = ['Content-Type' => 'application/json'];
     $response = $client->post($path, $fp, $headers);
     $contents = $response->getBody()->getContents();
     $reply = Json::decode($contents);
     if ($reply->responseHeader->status != 0) {
         throw new \Exception("Solr returned an error.");
     }
     $time = $reply->responseHeader->QTime;
     $output->writeln("Time taken: <comment>{$time} ms</comment>\n");
 }
예제 #3
0
파일: JsonTest.php 프로젝트: opendi/lang
 /**
  * @expectedException Exception
  * @expectedExceptionMessage Failed decoding JSON
  */
 public function testDecodeError()
 {
     // Invalid JSON
     Json::decode('xxx');
 }
예제 #4
0
파일: Core.php 프로젝트: opendi/solrclient
 /**
  * Pings the server to check it's there.
  *
  * @return array Decoded response from the Solr server.
  */
 public function ping()
 {
     $path = implode('/', [$this->name, $this->pingHandler]);
     $path = "{$path}?wt=json";
     $response = $this->client->get($path);
     $contents = $response->getBody()->getContents();
     return Json::decode($contents, true);
 }