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 buildWhereClauseParts(AphrontDatabaseConnection
$conn) {
42 $where = parent
::buildWhereClauseParts($conn);
44 if ($this->ids
!== null) {
51 if ($this->objectPHIDs
!== null) {
54 'objectPHID IN (%Ls)',
58 if ($this->tokens
!== null) {
65 if ($this->tokenTypes
!== null) {
72 if ($this->expired
!== null) {
77 PhabricatorTime
::getNow());
81 'expires IS NULL OR expires > %d',
82 PhabricatorTime
::getNow());
89 protected function willFilterPage(array $tokens) {
90 $object_phids = mpull($tokens, 'getObjectPHID');
91 $objects = id(new PhabricatorObjectQuery())
92 ->setViewer($this->getViewer())
93 ->setParentQuery($this)
94 ->withPHIDs($object_phids)
96 $objects = mpull($objects, null, 'getPHID');
98 foreach ($tokens as $key => $token) {
99 $object = idx($objects, $token->getObjectPHID(), null);
101 $this->didRejectResult($token);
102 unset($tokens[$key]);
105 $token->attachObject($object);
111 public function getQueryApplicationClass() {
112 return 'PhabricatorConduitApplication';