@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 89 lines 1.8 kB view raw
1<?php 2 3/** 4 * @extends PhabricatorCursorPagedPolicyAwareQuery<PhabricatorAuthProviderConfig> 5 */ 6final class PhabricatorAuthProviderConfigQuery 7 extends PhabricatorCursorPagedPolicyAwareQuery { 8 9 private $ids; 10 private $phids; 11 private $providerClasses; 12 private $isEnabled; 13 14 public function withPHIDs(array $phids) { 15 $this->phids = $phids; 16 return $this; 17 } 18 19 public function withIDs(array $ids) { 20 $this->ids = $ids; 21 return $this; 22 } 23 24 public function withProviderClasses(array $classes) { 25 $this->providerClasses = $classes; 26 return $this; 27 } 28 29 public function withIsEnabled($is_enabled) { 30 $this->isEnabled = $is_enabled; 31 return $this; 32 } 33 34 public function newResultObject() { 35 return new PhabricatorAuthProviderConfig(); 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->providerClasses !== null) { 56 $where[] = qsprintf( 57 $conn, 58 'providerClass IN (%Ls)', 59 $this->providerClasses); 60 } 61 62 if ($this->isEnabled !== null) { 63 $where[] = qsprintf( 64 $conn, 65 'isEnabled = %d', 66 (int)$this->isEnabled); 67 } 68 69 return $where; 70 } 71 72 protected function willFilterPage(array $configs) { 73 74 foreach ($configs as $key => $config) { 75 $provider = $config->getProvider(); 76 if (!$provider) { 77 unset($configs[$key]); 78 continue; 79 } 80 } 81 82 return $configs; 83 } 84 85 public function getQueryApplicationClass() { 86 return PhabricatorAuthApplication::class; 87 } 88 89}