[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class FundInitiativeQuery 4 extends PhabricatorCursorPagedPolicyAwareQuery { 5 6 private $ids; 7 private $phids; 8 private $ownerPHIDs; 9 private $statuses; 10 11 private $needProjectPHIDs; 12 13 public function withIDs(array $ids) { 14 $this->ids = $ids; 15 return $this; 16 } 17 18 public function withPHIDs(array $phids) { 19 $this->phids = $phids; 20 return $this; 21 } 22 23 public function withOwnerPHIDs(array $phids) { 24 $this->ownerPHIDs = $phids; 25 return $this; 26 } 27 28 public function withStatuses(array $statuses) { 29 $this->statuses = $statuses; 30 return $this; 31 } 32 33 public function needProjectPHIDs($need) { 34 $this->needProjectPHIDs = $need; 35 return $this; 36 } 37 38 protected function loadPage() { 39 $table = new FundInitiative(); 40 $conn_r = $table->establishConnection('r'); 41 42 $rows = queryfx_all( 43 $conn_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)); 49 50 return $table->loadAllFromArray($rows); 51 } 52 53 protected function didFilterPage(array $initiatives) { 54 55 if ($this->needProjectPHIDs) { 56 $edge_query = id(new PhabricatorEdgeQuery()) 57 ->withSourcePHIDs(mpull($initiatives, 'getPHID')) 58 ->withEdgeTypes( 59 array( 60 PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, 61 )); 62 $edge_query->execute(); 63 64 foreach ($initiatives as $initiative) { 65 $phids = $edge_query->getDestinationPHIDs( 66 array( 67 $initiative->getPHID(), 68 )); 69 $initiative->attachProjectPHIDs($phids); 70 } 71 } 72 73 return $initiatives; 74 } 75 76 private function buildWhereClause(AphrontDatabaseConnection $conn_r) { 77 $where = array(); 78 79 $where[] = $this->buildPagingClause($conn_r); 80 81 if ($this->ids !== null) { 82 $where[] = qsprintf( 83 $conn_r, 84 'id IN (%Ld)', 85 $this->ids); 86 } 87 88 if ($this->phids !== null) { 89 $where[] = qsprintf( 90 $conn_r, 91 'phid IN (%Ls)', 92 $this->phids); 93 } 94 95 if ($this->ownerPHIDs !== null) { 96 $where[] = qsprintf( 97 $conn_r, 98 'ownerPHID IN (%Ls)', 99 $this->ownerPHIDs); 100 } 101 102 if ($this->statuses !== null) { 103 $where[] = qsprintf( 104 $conn_r, 105 'status IN (%Ls)', 106 $this->statuses); 107 } 108 109 return $this->formatWhereClause($where); 110 } 111 112 public function getQueryApplicationClass() { 113 return 'PhabricatorFundApplication'; 114 } 115 116 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |