3 final class PhabricatorConduitTokenQuery
4 extends PhabricatorCursorPagedPolicyAwareQuery
{
12 public function withExpired($expired) {
13 $this->expired
= $expired;
17 public function withIDs(array $ids) {
22 public function withObjectPHIDs(array $phids) {
23 $this->objectPHIDs
= $phids;
27 public function withTokens(array $tokens) {
28 $this->tokens
= $tokens;
32 public function withTokenTypes(array $types) {
33 $this->tokenTypes
= $types;
37 public function newResultObject() {
38 return new PhabricatorConduitToken();
41 protected function loadPage() {
42 return $this->loadStandardPage($this->newResultObject());
45 protected function buildWhereClauseParts(AphrontDatabaseConnection
$conn) {
46 $where = parent
::buildWhereClauseParts($conn);
48 if ($this->ids
!== null) {
55 if ($this->objectPHIDs
!== null) {
58 'objectPHID IN (%Ls)',
62 if ($this->tokens
!== null) {
69 if ($this->tokenTypes
!== null) {
76 if ($this->expired
!== null) {
81 PhabricatorTime
::getNow());
85 'expires IS NULL OR expires > %d',
86 PhabricatorTime
::getNow());
93 protected function willFilterPage(array $tokens) {
94 $object_phids = mpull($tokens, 'getObjectPHID');
95 $objects = id(new PhabricatorObjectQuery())
96 ->setViewer($this->getViewer())
97 ->setParentQuery($this)
98 ->withPHIDs($object_phids)
100 $objects = mpull($objects, null, 'getPHID');
102 foreach ($tokens as $key => $token) {
103 $object = idx($objects, $token->getObjectPHID(), null);
105 $this->didRejectResult($token);
106 unset($tokens[$key]);
109 $token->attachObject($object);
115 public function getQueryApplicationClass() {
116 return 'PhabricatorConduitApplication';