@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 AlmanacBindingSearchEngine
4 extends PhabricatorApplicationSearchEngine {
5
6 public function getResultTypeDescription() {
7 return pht('Almanac Bindings');
8 }
9
10 public function getApplicationClassName() {
11 return PhabricatorAlmanacApplication::class;
12 }
13
14 public function newQuery() {
15 return new AlmanacBindingQuery();
16 }
17
18 protected function buildCustomSearchFields() {
19 return array(
20 id(new PhabricatorPHIDsSearchField())
21 ->setLabel(pht('Services'))
22 ->setKey('servicePHIDs')
23 ->setAliases(array('service', 'servicePHID', 'services'))
24 ->setDescription(pht('Search for bindings on particular services.')),
25 id(new PhabricatorPHIDsSearchField())
26 ->setLabel(pht('Devices'))
27 ->setKey('devicePHIDs')
28 ->setAliases(array('device', 'devicePHID', 'devices'))
29 ->setDescription(pht('Search for bindings on particular devices.')),
30 );
31 }
32
33 protected function buildQueryFromParameters(array $map) {
34 $query = $this->newQuery();
35
36 if ($map['servicePHIDs']) {
37 $query->withServicePHIDs($map['servicePHIDs']);
38 }
39
40 if ($map['devicePHIDs']) {
41 $query->withDevicePHIDs($map['devicePHIDs']);
42 }
43
44 return $query;
45 }
46
47 protected function getURI($path) {
48 return '/almanac/binding/'.$path;
49 }
50
51 protected function getBuiltinQueryNames() {
52 $names = array(
53 'all' => pht('All Bindings'),
54 );
55
56 return $names;
57 }
58
59 public function buildSavedQueryFromBuiltin($query_key) {
60 $query = $this->newSavedQuery();
61 $query->setQueryKey($query_key);
62
63 switch ($query_key) {
64 case 'all':
65 return $query;
66 }
67
68 return parent::buildSavedQueryFromBuiltin($query_key);
69 }
70
71 protected function renderResultList(
72 array $devices,
73 PhabricatorSavedQuery $query,
74 array $handles) {
75
76 // For now, this SearchEngine just supports API access via Conduit.
77 throw new PhutilMethodNotImplementedException();
78 }
79
80}