Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/query/DifferentialChangesetQuery.php
| <?php | <?php | ||||
| final class DifferentialChangesetQuery | final class DifferentialChangesetQuery | ||||
| extends PhabricatorCursorPagedPolicyAwareQuery { | extends PhabricatorCursorPagedPolicyAwareQuery { | ||||
| private $ids; | private $ids; | ||||
| private $phids; | |||||
| private $diffPHIDs; | |||||
| private $diffs; | private $diffs; | ||||
| private $needAttachToDiffs; | private $needAttachToDiffs; | ||||
| private $needHunks; | private $needHunks; | ||||
| 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) { | |||||
| $this->phids = $phids; | |||||
| return $this; | |||||
| } | |||||
| public function withDiffs(array $diffs) { | public function withDiffs(array $diffs) { | ||||
| assert_instances_of($diffs, 'DifferentialDiff'); | assert_instances_of($diffs, 'DifferentialDiff'); | ||||
| $this->diffs = $diffs; | $this->diffs = $diffs; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function withDiffPHIDs(array $phids) { | |||||
| $this->diffPHIDs = $phids; | |||||
| return $this; | |||||
| } | |||||
| public function needAttachToDiffs($attach) { | public function needAttachToDiffs($attach) { | ||||
| $this->needAttachToDiffs = $attach; | $this->needAttachToDiffs = $attach; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function needHunks($need) { | public function needHunks($need) { | ||||
| $this->needHunks = $need; | $this->needHunks = $need; | ||||
| return $this; | return $this; | ||||
| ▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
| if ($this->ids !== null) { | if ($this->ids !== null) { | ||||
| $where[] = qsprintf( | $where[] = qsprintf( | ||||
| $conn, | $conn, | ||||
| 'id IN (%Ld)', | 'id IN (%Ld)', | ||||
| $this->ids); | $this->ids); | ||||
| } | } | ||||
| if ($this->phids !== null) { | |||||
| $where[] = qsprintf( | |||||
| $conn, | |||||
| 'phid IN (%Ls)', | |||||
| $this->phids); | |||||
| } | |||||
| if ($this->diffPHIDs !== null) { | |||||
| $diff_ids = queryfx_all( | |||||
| $conn, | |||||
| 'SELECT id FROM %R WHERE phid IN (%Ls)', | |||||
| new DifferentialDiff(), | |||||
| $this->diffPHIDs); | |||||
| $diff_ids = ipull($diff_ids, 'id', null); | |||||
| if (!$diff_ids) { | |||||
| throw new PhabricatorEmptyQueryException(); | |||||
| } | |||||
| $where[] = qsprintf( | |||||
| $conn, | |||||
| 'diffID IN (%Ld)', | |||||
| $diff_ids); | |||||
| } | |||||
| return $where; | return $where; | ||||
| } | } | ||||
| public function getQueryApplicationClass() { | public function getQueryApplicationClass() { | ||||
| return 'PhabricatorDifferentialApplication'; | return 'PhabricatorDifferentialApplication'; | ||||
| } | } | ||||
| } | } | ||||