本文整理汇总了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;
}
示例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)');
}