Differential D21227 Diff 50563 src/applications/transactions/query/PhabricatorApplicationTransactionCommentQuery.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/query/PhabricatorApplicationTransactionCommentQuery.php
<?php | <?php | ||||
abstract class PhabricatorApplicationTransactionCommentQuery | abstract class PhabricatorApplicationTransactionCommentQuery | ||||
extends PhabricatorCursorPagedPolicyAwareQuery { | extends PhabricatorCursorPagedPolicyAwareQuery { | ||||
private $ids; | private $ids; | ||||
private $authorPHIDs; | private $authorPHIDs; | ||||
private $phids; | private $phids; | ||||
private $transactionPHIDs; | private $transactionPHIDs; | ||||
private $isDeleted; | private $isDeleted; | ||||
private $hasTransaction; | private $hasTransaction; | ||||
abstract protected function getTemplate(); | abstract protected function newApplicationTransactionCommentTemplate(); | ||||
public function withIDs(array $ids) { | public function withIDs(array $ids) { | ||||
$this->ids = $ids; | $this->ids = $ids; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withPHIDs(array $phids) { | public function withPHIDs(array $phids) { | ||||
$this->phids = $phids; | $this->phids = $phids; | ||||
Show All 15 Lines | public function withIsDeleted($deleted) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function withHasTransaction($has_transaction) { | public function withHasTransaction($has_transaction) { | ||||
$this->hasTransaction = $has_transaction; | $this->hasTransaction = $has_transaction; | ||||
return $this; | return $this; | ||||
} | } | ||||
protected function loadPage() { | public function newResultObject() { | ||||
$table = $this->getTemplate(); | return $this->newApplicationTransactionCommentTemplate(); | ||||
$conn_r = $table->establishConnection('r'); | |||||
$data = queryfx_all( | |||||
$conn_r, | |||||
'SELECT * FROM %T xcomment %Q %Q %Q', | |||||
$table->getTableName(), | |||||
$this->buildWhereClause($conn_r), | |||||
$this->buildOrderClause($conn_r), | |||||
$this->buildLimitClause($conn_r)); | |||||
return $table->loadAllFromArray($data); | |||||
} | } | ||||
protected function buildWhereClause(AphrontDatabaseConnection $conn) { | protected function loadPage() { | ||||
return $this->formatWhereClause( | return $this->loadStandardPage($this->newResultObject()); | ||||
$conn, | |||||
$this->buildWhereClauseComponents($conn)); | |||||
} | } | ||||
protected function buildWhereClauseComponents( | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
AphrontDatabaseConnection $conn) { | $where = parent::buildWhereClauseParts($conn); | ||||
$alias = $this->getPrimaryTableAlias(); | |||||
$where = array(); | |||||
if ($this->ids !== null) { | if ($this->ids !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'xcomment.id IN (%Ld)', | '%T.id IN (%Ld)', | ||||
$alias, | |||||
$this->ids); | $this->ids); | ||||
} | } | ||||
if ($this->phids !== null) { | if ($this->phids !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'xcomment.phid IN (%Ls)', | '%T.phid IN (%Ls)', | ||||
$alias, | |||||
$this->phids); | $this->phids); | ||||
} | } | ||||
if ($this->authorPHIDs !== null) { | if ($this->authorPHIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'xcomment.authorPHID IN (%Ls)', | '%T.authorPHID IN (%Ls)', | ||||
$alias, | |||||
$this->authorPHIDs); | $this->authorPHIDs); | ||||
} | } | ||||
if ($this->transactionPHIDs !== null) { | if ($this->transactionPHIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'xcomment.transactionPHID IN (%Ls)', | '%T.transactionPHID IN (%Ls)', | ||||
$alias, | |||||
$this->transactionPHIDs); | $this->transactionPHIDs); | ||||
} | } | ||||
if ($this->isDeleted !== null) { | if ($this->isDeleted !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'xcomment.isDeleted = %d', | '%T.isDeleted = %d', | ||||
$alias, | |||||
(int)$this->isDeleted); | (int)$this->isDeleted); | ||||
} | } | ||||
if ($this->hasTransaction !== null) { | if ($this->hasTransaction !== null) { | ||||
if ($this->hasTransaction) { | if ($this->hasTransaction) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'xcomment.transactionPHID IS NOT NULL'); | '%T.transactionPHID IS NOT NULL', | ||||
$alias); | |||||
} else { | } else { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'xcomment.transactionPHID IS NULL'); | '%T.transactionPHID IS NULL', | ||||
$alias); | |||||
} | } | ||||
} | } | ||||
return $where; | return $where; | ||||
} | } | ||||
protected function getPrimaryTableAlias() { | |||||
return 'xcomment'; | |||||
} | |||||
public function getQueryApplicationClass() { | public function getQueryApplicationClass() { | ||||
// TODO: Figure out the app via the template? | // TODO: Figure out the app via the template? | ||||
return null; | return null; | ||||
} | } | ||||
} | } |