Path: blob/master/src/applications/auth/query/PhabricatorAuthFactorConfigQuery.php
12262 views
<?php12final class PhabricatorAuthFactorConfigQuery3extends PhabricatorCursorPagedPolicyAwareQuery {45private $ids;6private $phids;7private $userPHIDs;8private $factorProviderPHIDs;9private $factorProviderStatuses;1011public function withIDs(array $ids) {12$this->ids = $ids;13return $this;14}1516public function withPHIDs(array $phids) {17$this->phids = $phids;18return $this;19}2021public function withUserPHIDs(array $user_phids) {22$this->userPHIDs = $user_phids;23return $this;24}2526public function withFactorProviderPHIDs(array $provider_phids) {27$this->factorProviderPHIDs = $provider_phids;28return $this;29}3031public function withFactorProviderStatuses(array $statuses) {32$this->factorProviderStatuses = $statuses;33return $this;34}3536public function newResultObject() {37return new PhabricatorAuthFactorConfig();38}3940protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {41$where = parent::buildWhereClauseParts($conn);4243if ($this->ids !== null) {44$where[] = qsprintf(45$conn,46'config.id IN (%Ld)',47$this->ids);48}4950if ($this->phids !== null) {51$where[] = qsprintf(52$conn,53'config.phid IN (%Ls)',54$this->phids);55}5657if ($this->userPHIDs !== null) {58$where[] = qsprintf(59$conn,60'config.userPHID IN (%Ls)',61$this->userPHIDs);62}6364if ($this->factorProviderPHIDs !== null) {65$where[] = qsprintf(66$conn,67'config.factorProviderPHID IN (%Ls)',68$this->factorProviderPHIDs);69}7071if ($this->factorProviderStatuses !== null) {72$where[] = qsprintf(73$conn,74'provider.status IN (%Ls)',75$this->factorProviderStatuses);76}7778return $where;79}8081protected function buildJoinClauseParts(AphrontDatabaseConnection $conn) {82$joins = parent::buildJoinClauseParts($conn);8384if ($this->factorProviderStatuses !== null) {85$joins[] = qsprintf(86$conn,87'JOIN %R provider ON config.factorProviderPHID = provider.phid',88new PhabricatorAuthFactorProvider());89}9091return $joins;92}9394protected function willFilterPage(array $configs) {95$provider_phids = mpull($configs, 'getFactorProviderPHID');9697$providers = id(new PhabricatorAuthFactorProviderQuery())98->setViewer($this->getViewer())99->withPHIDs($provider_phids)100->execute();101$providers = mpull($providers, null, 'getPHID');102103foreach ($configs as $key => $config) {104$provider = idx($providers, $config->getFactorProviderPHID());105106if (!$provider) {107unset($configs[$key]);108$this->didRejectResult($config);109continue;110}111112$config->attachFactorProvider($provider);113}114115return $configs;116}117118protected function getPrimaryTableAlias() {119return 'config';120}121122public function getQueryApplicationClass() {123return 'PhabricatorAuthApplication';124}125126}127128129