mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-15 11:22:40 +01:00
09ad69238e
Summary: Ref T7803. Ref T5873. Allows Query methods to expose orderings from the underlying Query class nearly-for-free. Callers can specify a string to use a builtin ordering, or an array to use a low-level column ordering. Test Plan: {F368236} Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T5873, T7803 Differential Revision: https://secure.phabricator.com/D12381
85 lines
2 KiB
PHP
85 lines
2 KiB
PHP
<?php
|
|
|
|
final class RepositoryQueryConduitAPIMethod
|
|
extends RepositoryConduitAPIMethod {
|
|
|
|
public function getAPIMethodName() {
|
|
return 'repository.query';
|
|
}
|
|
|
|
public function getMethodStatus() {
|
|
return self::METHOD_STATUS_UNSTABLE;
|
|
}
|
|
|
|
public function getMethodStatusDescription() {
|
|
return pht('Repository methods are new and subject to change.');
|
|
}
|
|
|
|
public function getMethodDescription() {
|
|
return pht('Query repositories.');
|
|
}
|
|
|
|
public function newQueryObject() {
|
|
return new PhabricatorRepositoryQuery();
|
|
}
|
|
|
|
protected function defineParamTypes() {
|
|
return array(
|
|
'ids' => 'optional list<int>',
|
|
'phids' => 'optional list<phid>',
|
|
'callsigns' => 'optional list<string>',
|
|
'vcsTypes' => 'optional list<string>',
|
|
'remoteURIs' => 'optional list<string>',
|
|
'uuids' => 'optional list<string>',
|
|
);
|
|
}
|
|
|
|
protected function defineReturnType() {
|
|
return 'list<dict>';
|
|
}
|
|
|
|
protected function execute(ConduitAPIRequest $request) {
|
|
$query = $this->newQueryForRequest($request);
|
|
|
|
$ids = $request->getValue('ids', array());
|
|
if ($ids) {
|
|
$query->withIDs($ids);
|
|
}
|
|
|
|
$phids = $request->getValue('phids', array());
|
|
if ($phids) {
|
|
$query->withPHIDs($phids);
|
|
}
|
|
|
|
$callsigns = $request->getValue('callsigns', array());
|
|
if ($callsigns) {
|
|
$query->withCallsigns($callsigns);
|
|
}
|
|
|
|
$vcs_types = $request->getValue('vcsTypes', array());
|
|
if ($vcs_types) {
|
|
$query->withTypes($vcs_types);
|
|
}
|
|
|
|
$remote_uris = $request->getValue('remoteURIs', array());
|
|
if ($remote_uris) {
|
|
$query->withRemoteURIs($remote_uris);
|
|
}
|
|
|
|
$uuids = $request->getValue('uuids', array());
|
|
if ($uuids) {
|
|
$query->withUUIDs($uuids);
|
|
}
|
|
|
|
$pager = $this->newPager($request);
|
|
$repositories = $query->executeWithCursorPager($pager);
|
|
|
|
$results = array();
|
|
foreach ($repositories as $repository) {
|
|
$results[] = $repository->toDictionary();
|
|
}
|
|
|
|
return $results;
|
|
}
|
|
|
|
}
|