当前位置: 首页>>代码示例>>PHP>>正文


PHP SMWQueryResult::serializeToArray方法代码示例

本文整理汇总了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;
 }
开发者ID:seedbank,项目名称:extension,代码行数:25,代码来源:api.php

示例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();
		}
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:26,代码来源:ApiSMWQuery.php

示例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());
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:12,代码来源:QueryResultTest.php

示例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();
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:31,代码来源:ApiSMWQuery.php


注:本文中的SMWQueryResult::serializeToArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。