Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/auth/query/PhabricatorAuthMessageQuery.php
12256 views
1
<?php
2
3
final class PhabricatorAuthMessageQuery
4
extends PhabricatorCursorPagedPolicyAwareQuery {
5
6
private $ids;
7
private $phids;
8
private $messageKeys;
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 withMessageKeys(array $keys) {
21
$this->messageKeys = $keys;
22
return $this;
23
}
24
25
public function newResultObject() {
26
return new PhabricatorAuthMessage();
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->messageKeys !== null) {
47
$where[] = qsprintf(
48
$conn,
49
'messageKey IN (%Ls)',
50
$this->messageKeys);
51
}
52
53
return $where;
54
}
55
56
protected function willFilterPage(array $messages) {
57
$message_types = PhabricatorAuthMessageType::getAllMessageTypes();
58
59
foreach ($messages as $key => $message) {
60
$message_key = $message->getMessageKey();
61
62
$message_type = idx($message_types, $message_key);
63
if (!$message_type) {
64
unset($messages[$key]);
65
$this->didRejectResult($message);
66
continue;
67
}
68
69
$message->attachMessageType($message_type);
70
}
71
72
return $messages;
73
}
74
75
public function getQueryApplicationClass() {
76
return 'PhabricatorAuthApplication';
77
}
78
79
}
80
81