本文整理汇总了PHP中SMWQueryResult::serializeToArray方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWQueryResult::serializeToArray方法的具体用法?PHP SMWQueryResult::serializeToArray怎么用?PHP SMWQueryResult::serializeToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMWQueryResult
的用法示例。
在下文中一共展示了SMWQueryResult::serializeToArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addQueryResult
protected function addQueryResult(SMWQueryResult $queryResult)
{
$serialized = $queryResult->serializeToArray();
$result = $this->getResult();
$result->setIndexedTagName($serialized['results'], 'result');
$result->setIndexedTagName($serialized['printrequests'], 'printrequest');
foreach ($serialized['results'] as $subjectName => $subject) {
if (is_array($subject) && array_key_exists('printouts', $subject)) {
foreach ($subject['printouts'] as $property => $values) {
if (is_array($values)) {
$result->setIndexedTagName($serialized['results'][$subjectName]['printouts'][$property], 'value');
}
}
}
}
$output = array();
header("Content-type: Application/JSON");
foreach ($serialized['results'] as $r) {
$common = count($r['printouts']['Has common name']) > 0 ? $r['printouts']['Has common name'][0]['fulltext'] : '';
$taxo = count($r['printouts']['Is taxonomy type']) > 0 ? $r['printouts']['Is taxonomy type'][0]['fulltext'] : '';
$output[$r['fulltext']] = array('taxonomy' => $taxo, 'common' => $common);
}
echo json_encode($output);
exit;
}
示例2: addQueryResult
protected function addQueryResult( SMWQueryResult $queryResult ) {
$serialized = $queryResult->serializeToArray();
$result = $this->getResult();
$result->setIndexedTagName( $serialized['results'], 'result' );
$result->setIndexedTagName( $serialized['printrequests'], 'printrequest' );
foreach ( $serialized['results'] as $subjectName => $subject ) {
if ( is_array( $subject ) && array_key_exists( 'printouts', $subject ) ) {
foreach ( $subject['printouts'] as $property => $values ) {
if ( is_array( $values ) ) {
$result->setIndexedTagName( $serialized['results'][$subjectName]['printouts'][$property], 'value' );
}
}
}
}
$result->addValue( null, 'query', $serialized );
if ( $queryResult->hasFurtherResults() ) {
// TODO: obtain continuation data from store
$result->disableSizeCheck();
$result->addValue( null, 'query-continue', 0 );
$result->enableSizeCheck();
}
}
示例3: testVerifyThatAfterSerializeToArrayResultNextCanBeUsed
public function testVerifyThatAfterSerializeToArrayResultNextCanBeUsed()
{
$query = $this->getMockBuilder('\\SMWQuery')->disableOriginalConstructor()->getMock();
$store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
$printRequests = array();
$results = array(new DIWikiPage('Foo', 0), new DIWikiPage('Bar', 0));
$instance = new QueryResult($printRequests, $query, $results, $store);
$instance->serializeToArray();
$this->assertInternalType('array', $instance->getNext());
$instance->getHash();
$this->assertInternalType('array', $instance->getNext());
}
示例4: addQueryResult
/**
* Add the query result to the API output.
*
* @since 1.6.2
*
* @param SMWQueryResult $queryResult
*/
protected function addQueryResult(SMWQueryResult $queryResult)
{
$serialized = $queryResult->serializeToArray();
$result = $this->getResult();
$result->setIndexedTagName($serialized['results'], 'result');
$result->setIndexedTagName($serialized['printrequests'], 'printrequest');
foreach ($serialized['results'] as $subjectName => $subject) {
if (is_array($subject) && array_key_exists('printouts', $subject)) {
foreach ($subject['printouts'] as $property => $values) {
if (is_array($values)) {
$result->setIndexedTagName($serialized['results'][$subjectName]['printouts'][$property], 'value');
}
}
}
}
$result->addValue(null, 'query', $serialized);
if ($queryResult->hasFurtherResults()) {
$result->disableSizeCheck();
// TODO: right now this returns an offset that we can use for continuation, just like done
// in other places in SMW. However, this is not efficient, so we should change this at some point.
$result->addValue(null, 'query-continue-offset', $this->parameters['offset']->getValue() + $queryResult->getCount());
$result->enableSizeCheck();
}
}