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


PHP ApiResult::stripMetadata方法代码示例

本文整理汇总了PHP中ApiResult::stripMetadata方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiResult::stripMetadata方法的具体用法?PHP ApiResult::stripMetadata怎么用?PHP ApiResult::stripMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ApiResult的用法示例。


在下文中一共展示了ApiResult::stripMetadata方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: flowApi

 /**
  * @param Title $title
  * @param string $submodule
  * @param array $request
  * @param bool $requiredBlock
  * @return array
  * @throws MWException
  */
 public function flowApi(Title $title, $submodule, array $request, $requiredBlock = false)
 {
     $request = new FauxRequest($request + array('action' => 'flow', 'submodule' => $submodule, 'page' => $title->getPrefixedText()));
     $api = new ApiMain($request);
     $api->execute();
     $flowData = $api->getResult()->getResultData(array('flow', $submodule, 'result'));
     if ($flowData === null) {
         throw new MWException("API response has no Flow data");
     }
     $flowData = ApiResult::stripMetadata($flowData);
     if ($requiredBlock !== false && !isset($flowData[$requiredBlock])) {
         throw new MWException("No {$requiredBlock} block in API response");
     }
     return $flowData;
 }
开发者ID:TarLocesilion,项目名称:mediawiki-extensions-Flow,代码行数:23,代码来源:convertToText.php

示例2: testUtilityFunctions

 /**
  * @covers ApiResult
  */
 public function testUtilityFunctions()
 {
     $arr = array('foo' => array('bar' => array('_dummy' => 'foobaz'), 'bar2' => (object) array('_dummy' => 'foobaz'), 'x' => 'ok', '_dummy' => 'foobaz'), 'foo2' => (object) array('bar' => array('_dummy' => 'foobaz'), 'bar2' => (object) array('_dummy' => 'foobaz'), 'x' => 'ok', '_dummy' => 'foobaz'), ApiResult::META_SUBELEMENTS => array('foo', 'bar'), ApiResult::META_INDEXED_TAG_NAME => 'itn', ApiResult::META_PRESERVE_KEYS => array('foo', 'bar', '_dummy2', 0), ApiResult::META_TYPE => 'array', '_dummy' => 'foobaz', '_dummy2' => 'foobaz!');
     $this->assertEquals(array('foo' => array('bar' => array(), 'bar2' => (object) array(), 'x' => 'ok'), 'foo2' => (object) array('bar' => array(), 'bar2' => (object) array(), 'x' => 'ok'), '_dummy2' => 'foobaz!'), ApiResult::stripMetadata($arr), 'ApiResult::stripMetadata');
     $metadata = array();
     $data = ApiResult::stripMetadataNonRecursive($arr, $metadata);
     $this->assertEquals(array('foo' => array('bar' => array('_dummy' => 'foobaz'), 'bar2' => (object) array('_dummy' => 'foobaz'), 'x' => 'ok', '_dummy' => 'foobaz'), 'foo2' => (object) array('bar' => array('_dummy' => 'foobaz'), 'bar2' => (object) array('_dummy' => 'foobaz'), 'x' => 'ok', '_dummy' => 'foobaz'), '_dummy2' => 'foobaz!'), $data, 'ApiResult::stripMetadataNonRecursive ($data)');
     $this->assertEquals(array(ApiResult::META_SUBELEMENTS => array('foo', 'bar'), ApiResult::META_INDEXED_TAG_NAME => 'itn', ApiResult::META_PRESERVE_KEYS => array('foo', 'bar', '_dummy2', 0), ApiResult::META_TYPE => 'array', '_dummy' => 'foobaz'), $metadata, 'ApiResult::stripMetadataNonRecursive ($metadata)');
     $metadata = null;
     $data = ApiResult::stripMetadataNonRecursive((object) $arr, $metadata);
     $this->assertEquals((object) array('foo' => array('bar' => array('_dummy' => 'foobaz'), 'bar2' => (object) array('_dummy' => 'foobaz'), 'x' => 'ok', '_dummy' => 'foobaz'), 'foo2' => (object) array('bar' => array('_dummy' => 'foobaz'), 'bar2' => (object) array('_dummy' => 'foobaz'), 'x' => 'ok', '_dummy' => 'foobaz'), '_dummy2' => 'foobaz!'), $data, 'ApiResult::stripMetadataNonRecursive on object ($data)');
     $this->assertEquals(array(ApiResult::META_SUBELEMENTS => array('foo', 'bar'), ApiResult::META_INDEXED_TAG_NAME => 'itn', ApiResult::META_PRESERVE_KEYS => array('foo', 'bar', '_dummy2', 0), ApiResult::META_TYPE => 'array', '_dummy' => 'foobaz'), $metadata, 'ApiResult::stripMetadataNonRecursive on object ($metadata)');
 }
开发者ID:ucfengzhun,项目名称:mediawiki,代码行数:16,代码来源:ApiResultTest.php


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