Path: blob/master/src/applications/harbormaster/query/HarbormasterBuildMessageQuery.php
12256 views
<?php12final class HarbormasterBuildMessageQuery3extends PhabricatorCursorPagedPolicyAwareQuery {45private $ids;6private $receiverPHIDs;7private $consumed;89public function withIDs(array $ids) {10$this->ids = $ids;11return $this;12}1314public function withReceiverPHIDs(array $phids) {15$this->receiverPHIDs = $phids;16return $this;17}1819public function withConsumed($consumed) {20$this->consumed = $consumed;21return $this;22}2324public function newResultObject() {25return new HarbormasterBuildMessage();26}2728protected function willFilterPage(array $page) {29$receiver_phids = array_filter(mpull($page, 'getReceiverPHID'));30if ($receiver_phids) {31$receivers = id(new PhabricatorObjectQuery())32->setViewer($this->getViewer())33->withPHIDs($receiver_phids)34->setParentQuery($this)35->execute();36$receivers = mpull($receivers, null, 'getPHID');37} else {38$receivers = array();39}4041foreach ($page as $key => $message) {42$receiver_phid = $message->getReceiverPHID();4344if (empty($receivers[$receiver_phid])) {45unset($page[$key]);46$this->didRejectResult($message);47continue;48}4950$message->attachReceiver($receivers[$receiver_phid]);51}5253return $page;54}5556protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {57$where = parent::buildWhereClauseParts($conn);5859if ($this->ids !== null) {60$where[] = qsprintf(61$conn,62'id IN (%Ld)',63$this->ids);64}6566if ($this->receiverPHIDs !== null) {67$where[] = qsprintf(68$conn,69'receiverPHID IN (%Ls)',70$this->receiverPHIDs);71}7273if ($this->consumed !== null) {74$where[] = qsprintf(75$conn,76'isConsumed = %d',77(int)$this->consumed);78}7980return $where;81}8283public function getQueryApplicationClass() {84return 'PhabricatorHarbormasterApplication';85}8687}888990