Changeset View
Changeset View
Standalone View
Standalone View
src/applications/fund/query/FundInitiativeQuery.php
Show All 29 Lines | public function withStatuses(array $statuses) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function needProjectPHIDs($need) { | public function needProjectPHIDs($need) { | ||||
$this->needProjectPHIDs = $need; | $this->needProjectPHIDs = $need; | ||||
return $this; | return $this; | ||||
} | } | ||||
protected function loadPage() { | public function newResultObject() { | ||||
$table = new FundInitiative(); | return new FundInitiative(); | ||||
$conn_r = $table->establishConnection('r'); | } | ||||
$rows = queryfx_all( | |||||
$conn_r, | |||||
'SELECT * FROM %T %Q %Q %Q', | |||||
$table->getTableName(), | |||||
$this->buildWhereClause($conn_r), | |||||
$this->buildOrderClause($conn_r), | |||||
$this->buildLimitClause($conn_r)); | |||||
return $table->loadAllFromArray($rows); | protected function loadPage() { | ||||
return $this->loadStandardPage($this->newResultObject()); | |||||
} | } | ||||
protected function didFilterPage(array $initiatives) { | protected function didFilterPage(array $initiatives) { | ||||
if ($this->needProjectPHIDs) { | if ($this->needProjectPHIDs) { | ||||
$edge_query = id(new PhabricatorEdgeQuery()) | $edge_query = id(new PhabricatorEdgeQuery()) | ||||
->withSourcePHIDs(mpull($initiatives, 'getPHID')) | ->withSourcePHIDs(mpull($initiatives, 'getPHID')) | ||||
->withEdgeTypes( | ->withEdgeTypes( | ||||
Show All 9 Lines | if ($this->needProjectPHIDs) { | ||||
)); | )); | ||||
$initiative->attachProjectPHIDs($phids); | $initiative->attachProjectPHIDs($phids); | ||||
} | } | ||||
} | } | ||||
return $initiatives; | return $initiatives; | ||||
} | } | ||||
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
$where = array(); | $where = parent::buildWhereClauseParts($conn); | ||||
$where[] = $this->buildPagingClause($conn_r); | |||||
if ($this->ids !== null) { | if ($this->ids !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn, | ||||
'id IN (%Ld)', | 'id IN (%Ld)', | ||||
$this->ids); | $this->ids); | ||||
} | } | ||||
if ($this->phids !== null) { | if ($this->phids !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn, | ||||
'phid IN (%Ls)', | 'phid IN (%Ls)', | ||||
$this->phids); | $this->phids); | ||||
} | } | ||||
if ($this->ownerPHIDs !== null) { | if ($this->ownerPHIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn, | ||||
'ownerPHID IN (%Ls)', | 'ownerPHID IN (%Ls)', | ||||
$this->ownerPHIDs); | $this->ownerPHIDs); | ||||
} | } | ||||
if ($this->statuses !== null) { | if ($this->statuses !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn, | ||||
'status IN (%Ls)', | 'status IN (%Ls)', | ||||
$this->statuses); | $this->statuses); | ||||
} | } | ||||
return $this->formatWhereClause($where); | return $where; | ||||
} | } | ||||
public function getQueryApplicationClass() { | public function getQueryApplicationClass() { | ||||
return 'PhabricatorFundApplication'; | return 'PhabricatorFundApplication'; | ||||
} | } | ||||
} | } |