@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class RepositoryQueryConduitAPIMethod
4 extends RepositoryConduitAPIMethod {
5
6 public function getAPIMethodName() {
7 return 'repository.query';
8 }
9
10 public function getMethodStatus() {
11 return self::METHOD_STATUS_FROZEN;
12 }
13
14 public function getMethodStatusDescription() {
15 return pht(
16 'This method is frozen and will eventually be deprecated. New code '.
17 'should use "diffusion.repository.search" instead.');
18 }
19
20 public function getMethodDescription() {
21 return pht('Query repositories.');
22 }
23
24 public function newQueryObject() {
25 return new PhabricatorRepositoryQuery();
26 }
27
28 protected function defineParamTypes() {
29 return array(
30 'ids' => 'optional list<int>',
31 'phids' => 'optional list<phid>',
32 'callsigns' => 'optional list<string>',
33 'vcsTypes' => 'optional list<string>',
34 'remoteURIs' => 'optional list<string>',
35 'uuids' => 'optional list<string>',
36 );
37 }
38
39 protected function defineReturnType() {
40 return 'list<dict>';
41 }
42
43 protected function execute(ConduitAPIRequest $request) {
44 $query = $this->newQueryForRequest($request);
45
46 $ids = $request->getValue('ids', array());
47 if ($ids) {
48 $query->withIDs($ids);
49 }
50
51 $phids = $request->getValue('phids', array());
52 if ($phids) {
53 $query->withPHIDs($phids);
54 }
55
56 $callsigns = $request->getValue('callsigns', array());
57 if ($callsigns) {
58 $query->withCallsigns($callsigns);
59 }
60
61 $vcs_types = $request->getValue('vcsTypes', array());
62 if ($vcs_types) {
63 $query->withTypes($vcs_types);
64 }
65
66 $remote_uris = $request->getValue('remoteURIs', array());
67 if ($remote_uris) {
68 $query->withURIs($remote_uris);
69 }
70
71 $uuids = $request->getValue('uuids', array());
72 if ($uuids) {
73 $query->withUUIDs($uuids);
74 }
75
76 $pager = $this->newPager($request);
77 $repositories = $query->executeWithCursorPager($pager);
78
79 $results = array();
80 foreach ($repositories as $repository) {
81 $results[] = $repository->toDictionary();
82 }
83
84 return $results;
85 }
86
87}