本文整理汇总了PHP中ApiResult::setArrayTypeRecursive方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiResult::setArrayTypeRecursive方法的具体用法?PHP ApiResult::setArrayTypeRecursive怎么用?PHP ApiResult::setArrayTypeRecursive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiResult
的用法示例。
在下文中一共展示了ApiResult::setArrayTypeRecursive方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
$params = $this->extractRequestParams();
$props = array_flip($params['prop']);
$repos = array();
$repoGroup = $this->getInitialisedRepoGroup();
$repoGroup->forEachForeignRepo(function ($repo) use(&$repos, $props) {
$repos[] = array_intersect_key($repo->getInfo(), $props);
});
$repos[] = array_intersect_key($repoGroup->getLocalRepo()->getInfo(), $props);
$result = $this->getResult();
ApiResult::setIndexedTagName($repos, 'repo');
ApiResult::setArrayTypeRecursive($repos, 'assoc');
ApiResult::setArrayType($repos, 'array');
$result->addValue(array('query'), 'repos', $repos);
}
示例2: execute
public function execute()
{
$conf = $this->getConfig();
$params = $this->extractRequestParams();
$props = array_flip($params['prop']);
$repos = [];
$repoGroup = $this->getInitialisedRepoGroup();
$foreignTargets = $conf->get('ForeignUploadTargets');
$repoGroup->forEachForeignRepo(function ($repo) use(&$repos, $props, $foreignTargets) {
$repoProps = $repo->getInfo();
$repoProps['canUpload'] = in_array($repoProps['name'], $foreignTargets);
$repos[] = array_intersect_key($repoProps, $props);
});
$localInfo = $repoGroup->getLocalRepo()->getInfo();
$localInfo['canUpload'] = $conf->get('EnableUploads');
$repos[] = array_intersect_key($localInfo, $props);
$result = $this->getResult();
ApiResult::setIndexedTagName($repos, 'repo');
ApiResult::setArrayTypeRecursive($repos, 'assoc');
ApiResult::setArrayType($repos, 'array');
$result->addValue(['query'], 'repos', $repos);
}
示例3: testMetadata
/**
* @covers ApiResult
*/
public function testMetadata()
{
$arr = array('foo' => array('bar' => array()));
$result = new ApiResult(8388608);
$result->addValue(null, 'foo', array('bar' => array()));
$expect = array('foo' => array('bar' => array(ApiResult::META_INDEXED_TAG_NAME => 'ritn', ApiResult::META_TYPE => 'default'), ApiResult::META_INDEXED_TAG_NAME => 'ritn', ApiResult::META_TYPE => 'default'), ApiResult::META_SUBELEMENTS => array('foo', 'bar'), ApiResult::META_INDEXED_TAG_NAME => 'itn', ApiResult::META_PRESERVE_KEYS => array('foo', 'bar'), ApiResult::META_TYPE => 'array');
ApiResult::setSubelementsList($arr, 'foo');
ApiResult::setSubelementsList($arr, array('bar', 'baz'));
ApiResult::unsetSubelementsList($arr, 'baz');
ApiResult::setIndexedTagNameRecursive($arr, 'ritn');
ApiResult::setIndexedTagName($arr, 'itn');
ApiResult::setPreserveKeysList($arr, 'foo');
ApiResult::setPreserveKeysList($arr, array('bar', 'baz'));
ApiResult::unsetPreserveKeysList($arr, 'baz');
ApiResult::setArrayTypeRecursive($arr, 'default');
ApiResult::setArrayType($arr, 'array');
$this->assertSame($expect, $arr);
$result->addSubelementsList(null, 'foo');
$result->addSubelementsList(null, array('bar', 'baz'));
$result->removeSubelementsList(null, 'baz');
$result->addIndexedTagNameRecursive(null, 'ritn');
$result->addIndexedTagName(null, 'itn');
$result->addPreserveKeysList(null, 'foo');
$result->addPreserveKeysList(null, array('bar', 'baz'));
$result->removePreserveKeysList(null, 'baz');
$result->addArrayTypeRecursive(null, 'default');
$result->addArrayType(null, 'array');
$this->assertEquals($expect, $result->getResultData());
$arr = array('foo' => array('bar' => array()));
$expect = array('foo' => array('bar' => array(ApiResult::META_TYPE => 'kvp', ApiResult::META_KVP_KEY_NAME => 'key'), ApiResult::META_TYPE => 'kvp', ApiResult::META_KVP_KEY_NAME => 'key'), ApiResult::META_TYPE => 'BCkvp', ApiResult::META_KVP_KEY_NAME => 'bc');
ApiResult::setArrayTypeRecursive($arr, 'kvp', 'key');
ApiResult::setArrayType($arr, 'BCkvp', 'bc');
$this->assertSame($expect, $arr);
}