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 loadPage() {
30 return $this->loadStandardPage($this->newResultObject());
33 protected function buildWhereClauseParts(AphrontDatabaseConnection
$conn) {
34 $where = parent
::buildWhereClauseParts($conn);
36 if ($this->authorPHIDs
!== null) {
39 'authorPHID IN (%Ls)',
43 if ($this->objectPHIDs
!== null) {
46 'objectPHID IN (%Ls)',
50 if ($this->tokenPHIDs
!== null) {
60 protected function willFilterPage(array $results) {
61 $viewer = $this->getViewer();
63 $object_phids = mpull($results, 'getObjectPHID');
65 $objects = id(new PhabricatorObjectQuery())
67 ->withPHIDs($object_phids)
69 $objects = mpull($objects, null, 'getPHID');
71 foreach ($results as $key => $result) {
72 $object = idx($objects, $result->getObjectPHID());
75 if ($object instanceof PhabricatorTokenReceiverInterface
) {
76 $result->attachObject($object);
81 $this->didRejectResult($result);
82 unset($results[$key]);
89 $token_phids = mpull($results, 'getTokenPHID');
91 $tokens = id(new PhabricatorTokenQuery())
93 ->withPHIDs($token_phids)
95 $tokens = mpull($tokens, null, 'getPHID');
97 foreach ($results as $key => $result) {
98 $token_phid = $result->getTokenPHID();
100 $token = idx($tokens, $token_phid);
102 $this->didRejectResult($result);
103 unset($results[$key]);
107 $result->attachToken($token);
113 public function getQueryApplicationClass() {
114 return 'PhabricatorTokensApplication';