コード例 #1
0
ファイル: afs_acp.php プロジェクト: antidot/php_api
 /** @brief Executes query.
  * @param $format [in] prefered result format.
  * @return Helper or array depending on chosen $format.
  */
 public function execute($format = AfsHelperFormat::ARRAYS)
 {
     $this->config->set_helper_format($format);
     $query_mgr = new AfsAcpQueryManager($this->connector, $this->config);
     $reply = $query_mgr->send($this->query);
     $helper = new AfsAcpResponseHelper($reply, $this->config);
     if (AfsHelperFormat::ARRAYS == $format) {
         return $helper->format();
     } else {
         return $helper;
     }
 }
コード例 #2
0
 public function testMultiFeedsAsArray()
 {
     $input = json_decode('{
         "foo": [
           "search",
           [ "suggest" ],
           [ { "key": "value"} ]
         ],
         "bar": [
           "search",
           [ "sugg" ]
         ]
       }', true);
     $response = new AfsAcpResponseHelper($input);
     $this->assertTrue($response->has_replyset());
     $result = $response->format();
     $this->assertEquals('search', $result['query_string']);
     $this->assertTrue(array_key_exists('foo', $result));
     $replyset = $result['foo'];
     $this->assertEquals('foo', $replyset['feed']);
     $replies = $replyset['replies'];
     $reply = reset($replies);
     $this->assertEquals('suggest', $reply['value']);
     $option = each($reply['options']);
     $this->assertEquals('key', $option[0]);
     $this->assertEquals('value', $option[1]);
     $this->assertTrue(array_key_exists('bar', $result));
     $replyset = $result['bar'];
     $this->assertEquals('bar', $replyset['feed']);
     $replies = $replyset['replies'];
     $reply = reset($replies);
     $this->assertEquals('sugg', $reply['value']);
     $this->assertTrue(empty($reply['options']));
 }