Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / harbormaster / conduit / HarbormasterQueryBuildsConduitAPIMethod.php
blobc4622a902cdd5d80ba328f7674ecb2f7ada8a6fe
1 <?php
3 final class HarbormasterQueryBuildsConduitAPIMethod
4 extends HarbormasterConduitAPIMethod {
6 public function getAPIMethodName() {
7 return 'harbormaster.querybuilds';
10 public function getMethodDescription() {
11 return pht('Query Harbormaster builds.');
14 public function getMethodStatus() {
15 return self::METHOD_STATUS_DEPRECATED;
18 public function getMethodStatusDescription() {
19 return pht('Use %s instead.', 'harbormaster.build.search');
22 protected function defineParamTypes() {
23 return array(
24 'ids' => 'optional list<id>',
25 'phids' => 'optional list<phid>',
26 'buildStatuses' => 'optional list<string>',
27 'buildablePHIDs' => 'optional list<phid>',
28 'buildPlanPHIDs' => 'optional list<phid>',
29 ) + self::getPagerParamTypes();
32 protected function defineReturnType() {
33 return 'wild';
36 protected function execute(ConduitAPIRequest $request) {
37 $viewer = $request->getUser();
38 $call = new ConduitCall(
39 'harbormaster.build.search',
40 array_filter(array(
41 'constraints' => array_filter(array(
42 'ids' => $request->getValue('ids'),
43 'phids' => $request->getValue('phids'),
44 'statuses' => $request->getValue('buildStatuses'),
45 'buildables' => $request->getValue('buildablePHIDs'),
46 'plans' => $request->getValue('buildPlanPHIDs'),
47 )),
48 'attachments' => array(
49 'querybuilds' => true,
51 'limit' => $request->getValue('limit'),
52 'before' => $request->getValue('before'),
53 'after' => $request->getValue('after'),
54 )));
56 $subsumption = $call->setUser($viewer)
57 ->execute();
59 $data = array();
60 foreach ($subsumption['data'] as $build_data) {
61 $querybuilds = idxv(
62 $build_data,
63 array('attachments', 'querybuilds'),
64 array());
65 $fields = idx($build_data, 'fields', array());
66 unset($build_data['fields']);
67 unset($build_data['attachments']);
69 // To retain backward compatibility, remove newer keys from the
70 // result array.
71 $fields['buildStatus'] = array_select_keys(
72 $fields['buildStatus'],
73 array(
74 'value',
75 'name',
76 ));
78 $data[] = array_mergev(array($build_data, $querybuilds, $fields));
81 $subsumption['data'] = $data;
83 return $subsumption;