Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/harbormaster/query/HarbormasterBuildUnitMessageQuery.php
12256 views
1
<?php
2
3
final class HarbormasterBuildUnitMessageQuery
4
extends PhabricatorCursorPagedPolicyAwareQuery {
5
6
private $ids;
7
private $phids;
8
private $targetPHIDs;
9
10
public function withIDs(array $ids) {
11
$this->ids = $ids;
12
return $this;
13
}
14
15
public function withPHIDs(array $phids) {
16
$this->phids = $phids;
17
return $this;
18
}
19
20
public function withBuildTargetPHIDs(array $target_phids) {
21
$this->targetPHIDs = $target_phids;
22
return $this;
23
}
24
25
public function newResultObject() {
26
return new HarbormasterBuildUnitMessage();
27
}
28
29
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
30
$where = parent::buildWhereClauseParts($conn);
31
32
if ($this->ids !== null) {
33
$where[] = qsprintf(
34
$conn,
35
'id IN (%Ld)',
36
$this->ids);
37
}
38
39
if ($this->phids !== null) {
40
$where[] = qsprintf(
41
$conn,
42
'phid in (%Ls)',
43
$this->phids);
44
}
45
46
if ($this->targetPHIDs !== null) {
47
$where[] = qsprintf(
48
$conn,
49
'buildTargetPHID in (%Ls)',
50
$this->targetPHIDs);
51
}
52
53
return $where;
54
}
55
56
protected function didFilterPage(array $messages) {
57
$indexes = array();
58
foreach ($messages as $message) {
59
$index = $message->getNameIndex();
60
if (strlen($index)) {
61
$indexes[$index] = $index;
62
}
63
}
64
65
if ($indexes) {
66
$map = HarbormasterString::newIndexMap($indexes);
67
68
foreach ($messages as $message) {
69
$index = $message->getNameIndex();
70
71
if (!strlen($index)) {
72
continue;
73
}
74
75
$name = idx($map, $index);
76
if ($name === null) {
77
$name = pht('Unknown Unit Message ("%s")', $index);
78
}
79
80
$message->setName($name);
81
}
82
}
83
84
return $messages;
85
}
86
87
public function getQueryApplicationClass() {
88
return 'PhabricatorHarbormasterApplication';
89
}
90
91
}
92
93