@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.0 kB view raw
1<?php 2 3/** 4 * @extends PhabricatorCursorPagedPolicyAwareQuery<PhabricatorAuthFactorProvider> 5 */ 6final class PhabricatorAuthFactorProviderQuery 7 extends PhabricatorCursorPagedPolicyAwareQuery { 8 9 private $ids; 10 private $phids; 11 private $statuses; 12 private $providerFactorKeys; 13 14 public function withIDs(array $ids) { 15 $this->ids = $ids; 16 return $this; 17 } 18 19 public function withPHIDs(array $phids) { 20 $this->phids = $phids; 21 return $this; 22 } 23 24 public function withProviderFactorKeys(array $keys) { 25 $this->providerFactorKeys = $keys; 26 return $this; 27 } 28 29 public function withStatuses(array $statuses) { 30 $this->statuses = $statuses; 31 return $this; 32 } 33 34 public function newResultObject() { 35 return new PhabricatorAuthFactorProvider(); 36 } 37 38 protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { 39 $where = parent::buildWhereClauseParts($conn); 40 41 if ($this->ids !== null) { 42 $where[] = qsprintf( 43 $conn, 44 'id IN (%Ld)', 45 $this->ids); 46 } 47 48 if ($this->phids !== null) { 49 $where[] = qsprintf( 50 $conn, 51 'phid IN (%Ls)', 52 $this->phids); 53 } 54 55 if ($this->statuses !== null) { 56 $where[] = qsprintf( 57 $conn, 58 'status IN (%Ls)', 59 $this->statuses); 60 } 61 62 if ($this->providerFactorKeys !== null) { 63 $where[] = qsprintf( 64 $conn, 65 'providerFactorKey IN (%Ls)', 66 $this->providerFactorKeys); 67 } 68 69 return $where; 70 } 71 72 protected function willFilterPage(array $providers) { 73 $map = PhabricatorAuthFactor::getAllFactors(); 74 foreach ($providers as $key => $provider) { 75 $factor_key = $provider->getProviderFactorKey(); 76 $factor = idx($map, $factor_key); 77 78 if (!$factor) { 79 unset($providers[$key]); 80 continue; 81 } 82 83 $provider->attachFactor($factor); 84 } 85 86 return $providers; 87 } 88 89 public function getQueryApplicationClass() { 90 return PhabricatorAuthApplication::class; 91 } 92 93}