[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorDashboardQuery 4 extends PhabricatorCursorPagedPolicyAwareQuery { 5 6 private $ids; 7 private $phids; 8 9 private $needPanels; 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 needPanels($need_panels) { 22 $this->needPanels = $need_panels; 23 return $this; 24 } 25 26 protected function loadPage() { 27 $table = new PhabricatorDashboard(); 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 protected function didFilterPage(array $dashboards) { 42 if ($this->needPanels) { 43 $edge_query = id(new PhabricatorEdgeQuery()) 44 ->withSourcePHIDs(mpull($dashboards, 'getPHID')) 45 ->withEdgeTypes( 46 array( 47 PhabricatorEdgeConfig::TYPE_DASHBOARD_HAS_PANEL, 48 )); 49 $edge_query->execute(); 50 51 $panel_phids = $edge_query->getDestinationPHIDs(); 52 if ($panel_phids) { 53 $panels = id(new PhabricatorDashboardPanelQuery()) 54 ->setParentQuery($this) 55 ->setViewer($this->getViewer()) 56 ->withPHIDs($panel_phids) 57 ->execute(); 58 $panels = mpull($panels, null, 'getPHID'); 59 } else { 60 $panels = array(); 61 } 62 63 foreach ($dashboards as $dashboard) { 64 $dashboard_phids = $edge_query->getDestinationPHIDs( 65 array($dashboard->getPHID())); 66 $dashboard_panels = array_select_keys($panels, $dashboard_phids); 67 68 $dashboard->attachPanelPHIDs($dashboard_phids); 69 $dashboard->attachPanels($dashboard_panels); 70 } 71 } 72 73 return $dashboards; 74 } 75 76 protected function buildWhereClause($conn_r) { 77 $where = array(); 78 79 if ($this->ids) { 80 $where[] = qsprintf( 81 $conn_r, 82 'id IN (%Ld)', 83 $this->ids); 84 } 85 86 if ($this->phids) { 87 $where[] = qsprintf( 88 $conn_r, 89 'phid IN (%Ls)', 90 $this->phids); 91 } 92 93 $where[] = $this->buildPagingClause($conn_r); 94 95 return $this->formatWhereClause($where); 96 } 97 98 public function getQueryApplicationClass() { 99 return 'PhabricatorDashboardApplication'; 100 } 101 102 }
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 |