@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 PhrictionContentSearchEngine
4 extends PhabricatorApplicationSearchEngine {
5
6 public function getResultTypeDescription() {
7 return pht('Phriction Document Content');
8 }
9
10 public function getApplicationClassName() {
11 return PhabricatorPhrictionApplication::class;
12 }
13
14 public function newQuery() {
15 return new PhrictionContentQuery();
16 }
17
18 protected function buildQueryFromParameters(array $map) {
19 $query = $this->newQuery();
20
21 if ($map['documentPHIDs']) {
22 $query->withDocumentPHIDs($map['documentPHIDs']);
23 }
24
25 if ($map['versions']) {
26 $query->withVersions($map['versions']);
27 }
28
29 return $query;
30 }
31
32 protected function buildCustomSearchFields() {
33 return array(
34 id(new PhabricatorPHIDsSearchField())
35 ->setKey('documentPHIDs')
36 ->setAliases(array('document', 'documents', 'documentPHID'))
37 ->setLabel(pht('Documents'))
38 ->setDescription(
39 pht(
40 'Search for documents with specific PHIDs.')),
41 id(new PhabricatorIDsSearchField())
42 ->setKey('versions')
43 ->setAliases(array('version'))
44 ->setLabel(pht('Versions'))
45 ->setDescription(
46 pht(
47 'Search for documents with specific versions.')),
48 );
49 }
50
51 protected function getURI($path) {
52 // There's currently no web UI for this search interface, it exists purely
53 // to power the Conduit API.
54 throw new PhutilMethodNotImplementedException();
55 }
56
57 protected function getBuiltinQueryNames() {
58 return array(
59 'all' => pht('All Content'),
60 );
61 }
62
63 public function buildSavedQueryFromBuiltin($query_key) {
64 $query = $this->newSavedQuery();
65 $query->setQueryKey($query_key);
66
67 switch ($query_key) {
68 case 'all':
69 return $query;
70 }
71
72 return parent::buildSavedQueryFromBuiltin($query_key);
73 }
74
75 /**
76 * @param array<PhrictionContent> $contents
77 * @param PhabricatorSavedQuery $query
78 * @param array<PhabricatorObjectHandle> $handles
79 */
80 protected function renderResultList(
81 array $contents,
82 PhabricatorSavedQuery $query,
83 array $handles) {
84 assert_instances_of($contents, PhrictionContent::class);
85 throw new PhutilMethodNotImplementedException();
86 }
87
88}