[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorRepositoryArcanistProjectQuery 4 extends PhabricatorCursorPagedPolicyAwareQuery { 5 6 private $ids; 7 private $phids; 8 9 private $needRepositories; 10 11 public function withIDs(array $ids) { 12 $this->ids = $ids; 13 return $this; 14 } 15 16 public function withPHIDs(array $phids) { 17 $this->phids = $phids; 18 return $this; 19 } 20 21 public function needRepositories($need_repositories) { 22 $this->needRepositories = $need_repositories; 23 return $this; 24 } 25 26 protected function loadPage() { 27 $table = new PhabricatorRepositoryArcanistProject(); 28 $conn_r = $table->establishConnection('r'); 29 30 $data = queryfx_all( 31 $conn_r, 32 'SELECT * FROM %T %Q %Q %Q', 33 $table->getTableName(), 34 $this->buildWhereClause($conn_r), 35 $this->buildOrderClause($conn_r), 36 $this->buildLimitClause($conn_r)); 37 38 return $table->loadAllFromArray($data); 39 } 40 41 public function willFilterPage(array $projects) { 42 assert_instances_of($projects, 'PhabricatorRepositoryArcanistProject'); 43 44 if ($this->needRepositories) { 45 $repository_ids = mpull($projects, 'getRepositoryID'); 46 $repositories = id(new PhabricatorRepositoryQuery()) 47 ->setViewer($this->getViewer()) 48 ->withIDs($repository_ids) 49 ->execute(); 50 foreach ($projects as $project) { 51 $repo = idx($repositories, $project->getRepositoryID()); 52 $project->attachRepository($repo); 53 } 54 } 55 56 return $projects; 57 } 58 59 private function buildWhereClause(AphrontDatabaseConnection $conn_r) { 60 $where = array(); 61 62 if ($this->ids) { 63 $where[] = qsprintf( 64 $conn_r, 65 'id IN (%Ld)', 66 $this->ids); 67 } 68 69 if ($this->phids) { 70 $where[] = qsprintf( 71 $conn_r, 72 'phid IN (%Ls)', 73 $this->phids); 74 } 75 76 $where[] = $this->buildPagingClause($conn_r); 77 78 return $this->formatWhereClause($where); 79 } 80 81 82 public function getQueryApplicationClass() { 83 // TODO: Diffusion? Differential? 84 return null; 85 } 86 87 }
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 |