Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/almanac/query/AlmanacNamespaceQuery.php
12256 views
1
<?php
2
3
final class AlmanacNamespaceQuery
4
extends AlmanacQuery {
5
6
private $ids;
7
private $phids;
8
private $names;
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 withNames(array $names) {
21
$this->names = $names;
22
return $this;
23
}
24
25
public function withNameNgrams($ngrams) {
26
return $this->withNgramsConstraint(
27
new AlmanacNamespaceNameNgrams(),
28
$ngrams);
29
}
30
31
public function newResultObject() {
32
return new AlmanacNamespace();
33
}
34
35
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
36
$where = parent::buildWhereClauseParts($conn);
37
38
if ($this->ids !== null) {
39
$where[] = qsprintf(
40
$conn,
41
'namespace.id IN (%Ld)',
42
$this->ids);
43
}
44
45
if ($this->phids !== null) {
46
$where[] = qsprintf(
47
$conn,
48
'namespace.phid IN (%Ls)',
49
$this->phids);
50
}
51
52
if ($this->names !== null) {
53
$where[] = qsprintf(
54
$conn,
55
'namespace.name IN (%Ls)',
56
$this->names);
57
}
58
59
return $where;
60
}
61
62
protected function getPrimaryTableAlias() {
63
return 'namespace';
64
}
65
66
public function getOrderableColumns() {
67
return parent::getOrderableColumns() + array(
68
'name' => array(
69
'table' => $this->getPrimaryTableAlias(),
70
'column' => 'name',
71
'type' => 'string',
72
'unique' => true,
73
'reverse' => true,
74
),
75
);
76
}
77
78
protected function newPagingMapFromPartialObject($object) {
79
return array(
80
'id' => (int)$object->getID(),
81
'name' => $object->getName(),
82
);
83
}
84
85
public function getBuiltinOrders() {
86
return array(
87
'name' => array(
88
'vector' => array('name'),
89
'name' => pht('Namespace Name'),
90
),
91
) + parent::getBuiltinOrders();
92
}
93
94
public function getQueryApplicationClass() {
95
return 'PhabricatorAlmanacApplication';
96
}
97
98
}
99
100