Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/harbormaster/query/HarbormasterBuildLogQuery.php
12256 views
1
<?php
2
3
final class HarbormasterBuildLogQuery
4
extends PhabricatorCursorPagedPolicyAwareQuery {
5
6
private $ids;
7
private $phids;
8
private $buildPHIDs;
9
private $buildTargetPHIDs;
10
11
public function withIDs(array $ids) {
12
$this->ids = $ids;
13
return $this;
14
}
15
16
public function withPHIDs(array $phids) {
17
$this->phids = $phids;
18
return $this;
19
}
20
21
public function withBuildTargetPHIDs(array $build_target_phids) {
22
$this->buildTargetPHIDs = $build_target_phids;
23
return $this;
24
}
25
26
public function newResultObject() {
27
return new HarbormasterBuildLog();
28
}
29
30
protected function willFilterPage(array $page) {
31
$build_targets = array();
32
33
$build_target_phids = array_filter(mpull($page, 'getBuildTargetPHID'));
34
if ($build_target_phids) {
35
$build_targets = id(new HarbormasterBuildTargetQuery())
36
->setViewer($this->getViewer())
37
->withPHIDs($build_target_phids)
38
->setParentQuery($this)
39
->execute();
40
$build_targets = mpull($build_targets, null, 'getPHID');
41
}
42
43
foreach ($page as $key => $build_log) {
44
$build_target_phid = $build_log->getBuildTargetPHID();
45
if (empty($build_targets[$build_target_phid])) {
46
unset($page[$key]);
47
continue;
48
}
49
$build_log->attachBuildTarget($build_targets[$build_target_phid]);
50
}
51
52
return $page;
53
}
54
55
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
56
$where = parent::buildWhereClauseParts($conn);
57
58
if ($this->ids !== null) {
59
$where[] = qsprintf(
60
$conn,
61
'id IN (%Ld)',
62
$this->ids);
63
}
64
65
if ($this->phids !== null) {
66
$where[] = qsprintf(
67
$conn,
68
'phid IN (%Ls)',
69
$this->phids);
70
}
71
72
if ($this->buildTargetPHIDs !== null) {
73
$where[] = qsprintf(
74
$conn,
75
'buildTargetPHID IN (%Ls)',
76
$this->buildTargetPHIDs);
77
}
78
79
return $where;
80
}
81
82
public function getQueryApplicationClass() {
83
return 'PhabricatorHarbormasterApplication';
84
}
85
86
}
87
88