Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/harbormaster/query/HarbormasterArtifactSearchEngine.php
12256 views
1
<?php
2
3
final class HarbormasterArtifactSearchEngine
4
extends PhabricatorApplicationSearchEngine {
5
6
public function getResultTypeDescription() {
7
return pht('Harbormaster Artifacts');
8
}
9
10
public function getApplicationClassName() {
11
return 'PhabricatorHarbormasterApplication';
12
}
13
14
public function newQuery() {
15
return new HarbormasterBuildArtifactQuery();
16
}
17
18
protected function buildCustomSearchFields() {
19
return array(
20
id(new PhabricatorPHIDsSearchField())
21
->setLabel(pht('Targets'))
22
->setKey('buildTargetPHIDs')
23
->setAliases(
24
array(
25
'buildTargetPHID',
26
'buildTargets',
27
'buildTarget',
28
'targetPHIDs',
29
'targetPHID',
30
'targets',
31
'target',
32
))
33
->setDescription(
34
pht('Search for artifacts attached to particular build targets.')),
35
);
36
}
37
38
protected function buildQueryFromParameters(array $map) {
39
$query = $this->newQuery();
40
41
if ($map['buildTargetPHIDs']) {
42
$query->withBuildTargetPHIDs($map['buildTargetPHIDs']);
43
}
44
45
return $query;
46
}
47
48
protected function getURI($path) {
49
return '/harbormaster/artifact/'.$path;
50
}
51
52
protected function getBuiltinQueryNames() {
53
return array(
54
'all' => pht('All Artifacts'),
55
);
56
}
57
58
public function buildSavedQueryFromBuiltin($query_key) {
59
$query = $this->newSavedQuery();
60
$query->setQueryKey($query_key);
61
62
switch ($query_key) {
63
case 'all':
64
return $query;
65
}
66
67
return parent::buildSavedQueryFromBuiltin($query_key);
68
}
69
70
protected function renderResultList(
71
array $artifacts,
72
PhabricatorSavedQuery $query,
73
array $handles) {
74
assert_instances_of($artifacts, 'HarbormasterBuildArtifact');
75
76
$viewer = $this->requireViewer();
77
78
$list = new PHUIObjectItemListView();
79
foreach ($artifacts as $artifact) {
80
$id = $artifact->getID();
81
82
$item = id(new PHUIObjectItemView())
83
->setObjectName(pht('Artifact %d', $id));
84
85
$list->addItem($item);
86
}
87
88
return id(new PhabricatorApplicationSearchResultView())
89
->setObjectList($list)
90
->setNoDataString(pht('No artifacts found.'));
91
}
92
93
}
94
95