Path: blob/master/src/applications/drydock/query/DrydockCommandQuery.php
12256 views
<?php12final class DrydockCommandQuery extends DrydockQuery {34private $ids;5private $targetPHIDs;6private $consumed;78public function withIDs(array $ids) {9$this->ids = $ids;10return $this;11}1213public function withTargetPHIDs(array $phids) {14$this->targetPHIDs = $phids;15return $this;16}1718public function withConsumed($consumed) {19$this->consumed = $consumed;20return $this;21}2223public function newResultObject() {24return new DrydockCommand();25}2627protected function willFilterPage(array $commands) {28$target_phids = mpull($commands, 'getTargetPHID');2930$targets = id(new PhabricatorObjectQuery())31->setViewer($this->getViewer())32->setParentQuery($this)33->withPHIDs($target_phids)34->execute();35$targets = mpull($targets, null, 'getPHID');3637foreach ($commands as $key => $command) {38$target = idx($targets, $command->getTargetPHID());39if (!$target) {40$this->didRejectResult($command);41unset($commands[$key]);42continue;43}44$command->attachCommandTarget($target);45}4647return $commands;48}4950protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {51$where = parent::buildWhereClauseParts($conn);5253if ($this->ids !== null) {54$where[] = qsprintf(55$conn,56'id IN (%Ld)',57$this->ids);58}5960if ($this->targetPHIDs !== null) {61$where[] = qsprintf(62$conn,63'targetPHID IN (%Ls)',64$this->targetPHIDs);65}6667if ($this->consumed !== null) {68$where[] = qsprintf(69$conn,70'isConsumed = %d',71(int)$this->consumed);72}7374return $where;75}7677}787980