[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class HarbormasterBuildStepQuery 4 extends PhabricatorCursorPagedPolicyAwareQuery { 5 6 private $ids; 7 private $phids; 8 private $buildPlanPHIDs; 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 withBuildPlanPHIDs(array $phids) { 21 $this->buildPlanPHIDs = $phids; 22 return $this; 23 } 24 25 protected function loadPage() { 26 $table = new HarbormasterBuildStep(); 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 private function buildWhereClause(AphrontDatabaseConnection $conn_r) { 41 $where = array(); 42 43 if ($this->ids) { 44 $where[] = qsprintf( 45 $conn_r, 46 'id IN (%Ld)', 47 $this->ids); 48 } 49 50 if ($this->phids) { 51 $where[] = qsprintf( 52 $conn_r, 53 'phid in (%Ls)', 54 $this->phids); 55 } 56 57 if ($this->buildPlanPHIDs) { 58 $where[] = qsprintf( 59 $conn_r, 60 'buildPlanPHID in (%Ls)', 61 $this->buildPlanPHIDs); 62 } 63 64 $where[] = $this->buildPagingClause($conn_r); 65 66 return $this->formatWhereClause($where); 67 } 68 69 protected function willFilterPage(array $page) { 70 $plans = array(); 71 72 $buildplan_phids = array_filter(mpull($page, 'getBuildPlanPHID')); 73 if ($buildplan_phids) { 74 $plans = id(new PhabricatorObjectQuery()) 75 ->setViewer($this->getViewer()) 76 ->withPHIDs($buildplan_phids) 77 ->setParentQuery($this) 78 ->execute(); 79 $plans = mpull($plans, null, 'getPHID'); 80 } 81 82 foreach ($page as $key => $build) { 83 $buildable_phid = $build->getBuildPlanPHID(); 84 if (empty($plans[$buildable_phid])) { 85 unset($page[$key]); 86 continue; 87 } 88 $build->attachBuildPlan($plans[$buildable_phid]); 89 } 90 91 return $page; 92 } 93 94 public function getQueryApplicationClass() { 95 return 'PhabricatorHarbormasterApplication'; 96 } 97 98 }
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 |