Remove product literal strings in "pht()", part 6
[phabricator.git] / src / applications / drydock / query / DrydockCommandQuery.php
blob0d71288a85fcddcb69e9d777aeb4777297008287
1 <?php
3 final class DrydockCommandQuery extends DrydockQuery {
5 private $ids;
6 private $targetPHIDs;
7 private $consumed;
9 public function withIDs(array $ids) {
10 $this->ids = $ids;
11 return $this;
14 public function withTargetPHIDs(array $phids) {
15 $this->targetPHIDs = $phids;
16 return $this;
19 public function withConsumed($consumed) {
20 $this->consumed = $consumed;
21 return $this;
24 public function newResultObject() {
25 return new DrydockCommand();
28 protected function loadPage() {
29 return $this->loadStandardPage($this->newResultObject());
32 protected function willFilterPage(array $commands) {
33 $target_phids = mpull($commands, 'getTargetPHID');
35 $targets = id(new PhabricatorObjectQuery())
36 ->setViewer($this->getViewer())
37 ->setParentQuery($this)
38 ->withPHIDs($target_phids)
39 ->execute();
40 $targets = mpull($targets, null, 'getPHID');
42 foreach ($commands as $key => $command) {
43 $target = idx($targets, $command->getTargetPHID());
44 if (!$target) {
45 $this->didRejectResult($command);
46 unset($commands[$key]);
47 continue;
49 $command->attachCommandTarget($target);
52 return $commands;
55 protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
56 $where = parent::buildWhereClauseParts($conn);
58 if ($this->ids !== null) {
59 $where[] = qsprintf(
60 $conn,
61 'id IN (%Ld)',
62 $this->ids);
65 if ($this->targetPHIDs !== null) {
66 $where[] = qsprintf(
67 $conn,
68 'targetPHID IN (%Ls)',
69 $this->targetPHIDs);
72 if ($this->consumed !== null) {
73 $where[] = qsprintf(
74 $conn,
75 'isConsumed = %d',
76 (int)$this->consumed);
79 return $where;