[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorOwnersPackageQuery 4 extends PhabricatorCursorPagedPolicyAwareQuery { 5 6 private $phids; 7 private $ownerPHIDs; 8 9 /** 10 * Owners are direct owners, and members of owning projects. 11 */ 12 public function withOwnerPHIDs(array $phids) { 13 $this->ownerPHIDs = $phids; 14 return $this; 15 } 16 17 public function withPHIDs(array $phids) { 18 $this->phids = $phids; 19 return $this; 20 } 21 22 protected function loadPage() { 23 $table = new PhabricatorOwnersPackage(); 24 $conn_r = $table->establishConnection('r'); 25 26 $data = queryfx_all( 27 $conn_r, 28 'SELECT p.* FROM %T p %Q %Q %Q %Q', 29 $table->getTableName(), 30 $this->buildJoinClause($conn_r), 31 $this->buildWhereClause($conn_r), 32 $this->buildOrderClause($conn_r), 33 $this->buildLimitClause($conn_r)); 34 35 return $table->loadAllFromArray($data); 36 } 37 38 private function buildJoinClause(AphrontDatabaseConnection $conn_r) { 39 $joins = array(); 40 41 if ($this->ownerPHIDs) { 42 $joins[] = qsprintf( 43 $conn_r, 44 'JOIN %T o ON o.packageID = p.id', 45 id(new PhabricatorOwnersOwner())->getTableName()); 46 } 47 48 return implode(' ', $joins); 49 } 50 51 private function buildWhereClause(AphrontDatabaseConnection $conn_r) { 52 $where = array(); 53 54 if ($this->phids) { 55 $where[] = qsprintf( 56 $conn_r, 57 'p.phid IN (%Ls)', 58 $this->phids); 59 } 60 61 if ($this->ownerPHIDs) { 62 $base_phids = $this->ownerPHIDs; 63 64 $query = new PhabricatorProjectQuery(); 65 $query->setViewer($this->getViewer()); 66 $query->withMemberPHIDs($base_phids); 67 $projects = $query->execute(); 68 $project_phids = mpull($projects, 'getPHID'); 69 70 $all_phids = array_merge($base_phids, $project_phids); 71 72 $where[] = qsprintf( 73 $conn_r, 74 'o.userPHID IN (%Ls)', 75 $all_phids); 76 } 77 78 $where[] = $this->buildPagingClause($conn_r); 79 return $this->formatWhereClause($where); 80 } 81 82 public function getQueryApplicationClass() { 83 return 'PhabricatorOwnersApplication'; 84 } 85 86 }
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 |