3 final class FundBackerQuery
4 extends PhabricatorCursorPagedPolicyAwareQuery
{
10 private $initiativePHIDs;
13 public function withIDs(array $ids) {
18 public function withPHIDs(array $phids) {
19 $this->phids
= $phids;
23 public function withStatuses(array $statuses) {
24 $this->statuses
= $statuses;
28 public function withInitiativePHIDs(array $phids) {
29 $this->initiativePHIDs
= $phids;
33 public function withBackerPHIDs(array $phids) {
34 $this->backerPHIDs
= $phids;
38 protected function loadPage() {
39 $table = new FundBacker();
40 $conn_r = $table->establishConnection('r');
44 'SELECT * FROM %T %Q %Q %Q',
45 $table->getTableName(),
46 $this->buildWhereClause($conn_r),
47 $this->buildOrderClause($conn_r),
48 $this->buildLimitClause($conn_r));
50 return $table->loadAllFromArray($rows);
53 protected function willFilterPage(array $backers) {
54 $initiative_phids = mpull($backers, 'getInitiativePHID');
55 $initiatives = id(new PhabricatorObjectQuery())
56 ->setParentQuery($this)
57 ->setViewer($this->getViewer())
58 ->withPHIDs($initiative_phids)
60 $initiatives = mpull($initiatives, null, 'getPHID');
62 foreach ($backers as $backer) {
63 $initiative_phid = $backer->getInitiativePHID();
64 $initiative = idx($initiatives, $initiative_phid);
65 $backer->attachInitiative($initiative);
71 protected function buildWhereClause(AphrontDatabaseConnection
$conn) {
74 $where[] = $this->buildPagingClause($conn);
76 if ($this->ids
!== null) {
83 if ($this->phids
!== null) {
90 if ($this->initiativePHIDs
!== null) {
93 'initiativePHID IN (%Ls)',
94 $this->initiativePHIDs
);
97 if ($this->backerPHIDs
!== null) {
100 'backerPHID IN (%Ls)',
104 if ($this->statuses
!== null) {
111 return $this->formatWhereClause($conn, $where);
114 public function getQueryApplicationClass() {
115 return 'PhabricatorFundApplication';