3 final class PhabricatorTokenGivenQuery
4 extends PhabricatorCursorPagedPolicyAwareQuery
{
10 public function withTokenPHIDs(array $token_phids) {
11 $this->tokenPHIDs
= $token_phids;
15 public function withObjectPHIDs(array $object_phids) {
16 $this->objectPHIDs
= $object_phids;
20 public function withAuthorPHIDs(array $author_phids) {
21 $this->authorPHIDs
= $author_phids;
25 public function newResultObject() {
26 return new PhabricatorTokenGiven();
29 protected function buildWhereClauseParts(AphrontDatabaseConnection
$conn) {
30 $where = parent
::buildWhereClauseParts($conn);
32 if ($this->authorPHIDs
!== null) {
35 'authorPHID IN (%Ls)',
39 if ($this->objectPHIDs
!== null) {
42 'objectPHID IN (%Ls)',
46 if ($this->tokenPHIDs
!== null) {
56 protected function willFilterPage(array $results) {
57 $viewer = $this->getViewer();
59 $object_phids = mpull($results, 'getObjectPHID');
61 $objects = id(new PhabricatorObjectQuery())
63 ->withPHIDs($object_phids)
65 $objects = mpull($objects, null, 'getPHID');
67 foreach ($results as $key => $result) {
68 $object = idx($objects, $result->getObjectPHID());
71 if ($object instanceof PhabricatorTokenReceiverInterface
) {
72 $result->attachObject($object);
77 $this->didRejectResult($result);
78 unset($results[$key]);
85 $token_phids = mpull($results, 'getTokenPHID');
87 $tokens = id(new PhabricatorTokenQuery())
89 ->withPHIDs($token_phids)
91 $tokens = mpull($tokens, null, 'getPHID');
93 foreach ($results as $key => $result) {
94 $token_phid = $result->getTokenPHID();
96 $token = idx($tokens, $token_phid);
98 $this->didRejectResult($result);
99 unset($results[$key]);
103 $result->attachToken($token);
109 public function getQueryApplicationClass() {
110 return 'PhabricatorTokensApplication';