Path: blob/master/src/applications/auth/query/PhabricatorAuthPasswordQuery.php
12262 views
<?php12final class PhabricatorAuthPasswordQuery3extends PhabricatorCursorPagedPolicyAwareQuery {45private $ids;6private $phids;7private $objectPHIDs;8private $passwordTypes;9private $isRevoked;1011public function withIDs(array $ids) {12$this->ids = $ids;13return $this;14}1516public function withPHIDs(array $phids) {17$this->phids = $phids;18return $this;19}2021public function withObjectPHIDs(array $object_phids) {22$this->objectPHIDs = $object_phids;23return $this;24}2526public function withPasswordTypes(array $types) {27$this->passwordTypes = $types;28return $this;29}3031public function withIsRevoked($is_revoked) {32$this->isRevoked = $is_revoked;33return $this;34}3536public function newResultObject() {37return new PhabricatorAuthPassword();38}3940protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {41$where = parent::buildWhereClauseParts($conn);4243if ($this->ids !== null) {44$where[] = qsprintf(45$conn,46'id IN (%Ld)',47$this->ids);48}4950if ($this->phids !== null) {51$where[] = qsprintf(52$conn,53'phid IN (%Ls)',54$this->phids);55}5657if ($this->objectPHIDs !== null) {58$where[] = qsprintf(59$conn,60'objectPHID IN (%Ls)',61$this->objectPHIDs);62}6364if ($this->passwordTypes !== null) {65$where[] = qsprintf(66$conn,67'passwordType IN (%Ls)',68$this->passwordTypes);69}7071if ($this->isRevoked !== null) {72$where[] = qsprintf(73$conn,74'isRevoked = %d',75(int)$this->isRevoked);76}7778return $where;79}8081protected function willFilterPage(array $passwords) {82$object_phids = mpull($passwords, 'getObjectPHID');8384$objects = id(new PhabricatorObjectQuery())85->setViewer($this->getViewer())86->setParentQuery($this)87->withPHIDs($object_phids)88->execute();89$objects = mpull($objects, null, 'getPHID');9091foreach ($passwords as $key => $password) {92$object = idx($objects, $password->getObjectPHID());93if (!$object) {94unset($passwords[$key]);95$this->didRejectResult($password);96continue;97}9899$password->attachObject($object);100}101102return $passwords;103}104105public function getQueryApplicationClass() {106return 'PhabricatorAuthApplication';107}108109}110111112