Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / auth / query / PhabricatorAuthMessageQuery.php
blob384c8de23b6c432e39a755c45d0b6e43a1933913
1 <?php
3 final class PhabricatorAuthMessageQuery
4 extends PhabricatorCursorPagedPolicyAwareQuery {
6 private $ids;
7 private $phids;
8 private $messageKeys;
10 public function withIDs(array $ids) {
11 $this->ids = $ids;
12 return $this;
15 public function withPHIDs(array $phids) {
16 $this->phids = $phids;
17 return $this;
20 public function withMessageKeys(array $keys) {
21 $this->messageKeys = $keys;
22 return $this;
25 public function newResultObject() {
26 return new PhabricatorAuthMessage();
29 protected function loadPage() {
30 return $this->loadStandardPage($this->newResultObject());
33 protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
34 $where = parent::buildWhereClauseParts($conn);
36 if ($this->ids !== null) {
37 $where[] = qsprintf(
38 $conn,
39 'id IN (%Ld)',
40 $this->ids);
43 if ($this->phids !== null) {
44 $where[] = qsprintf(
45 $conn,
46 'phid IN (%Ls)',
47 $this->phids);
50 if ($this->messageKeys !== null) {
51 $where[] = qsprintf(
52 $conn,
53 'messageKey IN (%Ls)',
54 $this->messageKeys);
57 return $where;
60 protected function willFilterPage(array $messages) {
61 $message_types = PhabricatorAuthMessageType::getAllMessageTypes();
63 foreach ($messages as $key => $message) {
64 $message_key = $message->getMessageKey();
66 $message_type = idx($message_types, $message_key);
67 if (!$message_type) {
68 unset($messages[$key]);
69 $this->didRejectResult($message);
70 continue;
73 $message->attachMessageType($message_type);
76 return $messages;
79 public function getQueryApplicationClass() {
80 return 'PhabricatorAuthApplication';