Differential D12027 Diff 28958 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; | |||||
| abstract protected function getTemplate(); | abstract protected function getTemplate(); | ||||
| 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; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withTransactionPHIDs(array $transaction_phids) { | public function withTransactionPHIDs(array $transaction_phids) { | ||||
| $this->transactionPHIDs = $transaction_phids; | $this->transactionPHIDs = $transaction_phids; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withAuthorPHIDs(array $phids) { | public function withAuthorPHIDs(array $phids) { | ||||
| $this->authorPHIDs = $phids; | $this->authorPHIDs = $phids; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withDeleted($deleted) { | public function withIsDeleted($deleted) { | ||||
| $this->isDeleted = $deleted; | $this->isDeleted = $deleted; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withHasTransaction($has_transaction) { | |||||
| $this->hasTransaction = $has_transaction; | |||||
| return $this; | |||||
| } | |||||
| protected function loadPage() { | protected function loadPage() { | ||||
| $table = $this->getTemplate(); | $table = $this->getTemplate(); | ||||
| $conn_r = $table->establishConnection('r'); | $conn_r = $table->establishConnection('r'); | ||||
| $data = queryfx_all( | $data = queryfx_all( | ||||
| $conn_r, | $conn_r, | ||||
| 'SELECT * FROM %T xcomment %Q %Q %Q', | 'SELECT * FROM %T xcomment %Q %Q %Q', | ||||
| $table->getTableName(), | $table->getTableName(), | ||||
| $this->buildWhereClause($conn_r), | $this->buildWhereClause($conn_r), | ||||
| $this->buildOrderClause($conn_r), | $this->buildOrderClause($conn_r), | ||||
| $this->buildLimitClause($conn_r)); | $this->buildLimitClause($conn_r)); | ||||
| return $table->loadAllFromArray($data); | return $table->loadAllFromArray($data); | ||||
| } | } | ||||
| protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { | private function buildWhereClause(AphrontDatabaseConnection $conn_r) { | ||||
| return $this->formatWhereClause($this->buildWhereClauseComponents($conn_r)); | |||||
| } | |||||
| protected function buildWhereClauseComponents( | |||||
| AphrontDatabaseConnection $conn_r) { | |||||
| $where = array(); | $where = array(); | ||||
| if ($this->ids !== null) { | if ($this->ids !== null) { | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| $conn_r, | $conn_r, | ||||
| 'xcomment.id IN (%Ld)', | 'xcomment.id IN (%Ld)', | ||||
| $this->ids); | $this->ids); | ||||
| } | } | ||||
| Show All 21 Lines | protected function buildWhereClauseComponents( | ||||
| if ($this->isDeleted !== null) { | if ($this->isDeleted !== null) { | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| $conn_r, | $conn_r, | ||||
| 'xcomment.isDeleted = %d', | 'xcomment.isDeleted = %d', | ||||
| (int)$this->isDeleted); | (int)$this->isDeleted); | ||||
| } | } | ||||
| return $this->formatWhereClause($where); | if ($this->hasTransaction !== null) { | ||||
| if ($this->hasTransaction) { | |||||
| $where[] = qsprintf( | |||||
| $conn_r, | |||||
| 'xcomment.transactionPHID IS NOT NULL'); | |||||
| } else { | |||||
| $where[] = qsprintf( | |||||
| $conn_r, | |||||
| 'xcomment.transactionPHID IS NULL'); | |||||
| } | |||||
| } | |||||
| return $where; | |||||
| } | } | ||||
| 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; | ||||
| } | } | ||||
| } | } | ||||