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