@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 PHIDQueryConduitAPIMethod extends PHIDConduitAPIMethod {
4
5 public function getAPIMethodName() {
6 return 'phid.query';
7 }
8
9 public function getMethodDescription() {
10 return pht('Retrieve information about arbitrary PHIDs.');
11 }
12
13 protected function defineParamTypes() {
14 return array(
15 'phids' => 'required list<phid>',
16 );
17 }
18
19 protected function defineReturnType() {
20 return 'nonempty dict<string, wild>';
21 }
22
23 protected function defineErrorTypes() {
24 return array(
25 'ERR-BAD-PHID' => pht('Must pass PHIDs.'),
26 );
27 }
28
29 protected function execute(ConduitAPIRequest $request) {
30 $phids = $request->getValue('phids');
31
32 if (!$phids) {
33 throw new ConduitException('ERR-BAD-PHID');
34 }
35
36 $handles = id(new PhabricatorHandleQuery())
37 ->setViewer($request->getUser())
38 ->withPHIDs($phids)
39 ->execute();
40
41 $result = array();
42 foreach ($handles as $phid => $handle) {
43 if ($handle->isComplete()) {
44 $result[$phid] = $this->buildHandleInformationDictionary($handle);
45 }
46 }
47
48 return $result;
49 }
50
51}