@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at recaptime-dev/main 93 lines 2.1 kB view raw
1<?php 2 3/** 4 * @extends PhabricatorCursorPagedPolicyAwareQuery<PhabricatorExternalAccountIdentifier> 5 */ 6final class PhabricatorExternalAccountIdentifierQuery 7 extends PhabricatorCursorPagedPolicyAwareQuery { 8 9 private $ids; 10 private $phids; 11 private $providerConfigPHIDs; 12 private $externalAccountPHIDs; 13 private $rawIdentifiers; 14 15 public function withIDs($ids) { 16 $this->ids = $ids; 17 return $this; 18 } 19 20 public function withPHIDs(array $phids) { 21 $this->phids = $phids; 22 return $this; 23 } 24 25 public function withProviderConfigPHIDs(array $phids) { 26 $this->providerConfigPHIDs = $phids; 27 return $this; 28 } 29 30 public function withExternalAccountPHIDs(array $phids) { 31 $this->externalAccountPHIDs = $phids; 32 return $this; 33 } 34 35 public function withRawIdentifiers(array $identifiers) { 36 $this->rawIdentifiers = $identifiers; 37 return $this; 38 } 39 40 public function newResultObject() { 41 return new PhabricatorExternalAccountIdentifier(); 42 } 43 44 protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { 45 $where = parent::buildWhereClauseParts($conn); 46 47 if ($this->ids !== null) { 48 $where[] = qsprintf( 49 $conn, 50 'id IN (%Ld)', 51 $this->ids); 52 } 53 54 if ($this->phids !== null) { 55 $where[] = qsprintf( 56 $conn, 57 'phid IN (%Ls)', 58 $this->phids); 59 } 60 61 if ($this->providerConfigPHIDs !== null) { 62 $where[] = qsprintf( 63 $conn, 64 'providerConfigPHID IN (%Ls)', 65 $this->providerConfigPHIDs); 66 } 67 68 if ($this->externalAccountPHIDs !== null) { 69 $where[] = qsprintf( 70 $conn, 71 'externalAccountPHID IN (%Ls)', 72 $this->externalAccountPHIDs); 73 } 74 75 if ($this->rawIdentifiers !== null) { 76 $hashes = array(); 77 foreach ($this->rawIdentifiers as $raw_identifier) { 78 $hashes[] = PhabricatorHash::digestForIndex($raw_identifier); 79 } 80 $where[] = qsprintf( 81 $conn, 82 'identifierHash IN (%Ls)', 83 $hashes); 84 } 85 86 return $where; 87 } 88 89 public function getQueryApplicationClass() { 90 return PhabricatorPeopleApplication::class; 91 } 92 93}