Path: blob/master/src/applications/conduit/query/PhabricatorConduitTokenQuery.php
12256 views
<?php12final class PhabricatorConduitTokenQuery3extends PhabricatorCursorPagedPolicyAwareQuery {45private $ids;6private $objectPHIDs;7private $expired;8private $tokens;9private $tokenTypes;1011public function withExpired($expired) {12$this->expired = $expired;13return $this;14}1516public function withIDs(array $ids) {17$this->ids = $ids;18return $this;19}2021public function withObjectPHIDs(array $phids) {22$this->objectPHIDs = $phids;23return $this;24}2526public function withTokens(array $tokens) {27$this->tokens = $tokens;28return $this;29}3031public function withTokenTypes(array $types) {32$this->tokenTypes = $types;33return $this;34}3536public function newResultObject() {37return new PhabricatorConduitToken();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->objectPHIDs !== null) {51$where[] = qsprintf(52$conn,53'objectPHID IN (%Ls)',54$this->objectPHIDs);55}5657if ($this->tokens !== null) {58$where[] = qsprintf(59$conn,60'token IN (%Ls)',61$this->tokens);62}6364if ($this->tokenTypes !== null) {65$where[] = qsprintf(66$conn,67'tokenType IN (%Ls)',68$this->tokenTypes);69}7071if ($this->expired !== null) {72if ($this->expired) {73$where[] = qsprintf(74$conn,75'expires <= %d',76PhabricatorTime::getNow());77} else {78$where[] = qsprintf(79$conn,80'expires IS NULL OR expires > %d',81PhabricatorTime::getNow());82}83}8485return $where;86}8788protected function willFilterPage(array $tokens) {89$object_phids = mpull($tokens, 'getObjectPHID');90$objects = id(new PhabricatorObjectQuery())91->setViewer($this->getViewer())92->setParentQuery($this)93->withPHIDs($object_phids)94->execute();95$objects = mpull($objects, null, 'getPHID');9697foreach ($tokens as $key => $token) {98$object = idx($objects, $token->getObjectPHID(), null);99if (!$object) {100$this->didRejectResult($token);101unset($tokens[$key]);102continue;103}104$token->attachObject($object);105}106107return $tokens;108}109110public function getQueryApplicationClass() {111return 'PhabricatorConduitApplication';112}113114}115116117