@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 76 lines 1.6 kB view raw
1<?php 2 3/** 4 * @extends PhabricatorCursorPagedPolicyAwareQuery<PhabricatorOAuthServerClient> 5 */ 6final class PhabricatorOAuthServerClientQuery 7 extends PhabricatorCursorPagedPolicyAwareQuery { 8 9 private $ids; 10 private $phids; 11 private $creatorPHIDs; 12 13 public function withIDs(array $ids) { 14 $this->ids = $ids; 15 return $this; 16 } 17 18 public function withPHIDs(array $phids) { 19 $this->phids = $phids; 20 return $this; 21 } 22 23 public function withCreatorPHIDs(array $phids) { 24 $this->creatorPHIDs = $phids; 25 return $this; 26 } 27 28 protected function loadPage() { 29 $table = new PhabricatorOAuthServerClient(); 30 $conn_r = $table->establishConnection('r'); 31 32 $data = queryfx_all( 33 $conn_r, 34 'SELECT * FROM %T client %Q %Q %Q', 35 $table->getTableName(), 36 $this->buildWhereClause($conn_r), 37 $this->buildOrderClause($conn_r), 38 $this->buildLimitClause($conn_r)); 39 40 return $table->loadAllFromArray($data); 41 } 42 43 protected function buildWhereClause(AphrontDatabaseConnection $conn) { 44 $where = array(); 45 46 if ($this->ids) { 47 $where[] = qsprintf( 48 $conn, 49 'id IN (%Ld)', 50 $this->ids); 51 } 52 53 if ($this->phids) { 54 $where[] = qsprintf( 55 $conn, 56 'phid IN (%Ls)', 57 $this->phids); 58 } 59 60 if ($this->creatorPHIDs) { 61 $where[] = qsprintf( 62 $conn, 63 'creatorPHID IN (%Ls)', 64 $this->creatorPHIDs); 65 } 66 67 $where[] = $this->buildPagingClause($conn); 68 69 return $this->formatWhereClause($conn, $where); 70 } 71 72 public function getQueryApplicationClass() { 73 return PhabricatorOAuthServerApplication::class; 74 } 75 76}