Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/query/PhabricatorExternalAccountQuery.php
| Show First 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
| return $where; | return $where; | ||||
| } | } | ||||
| public function getQueryApplicationClass() { | public function getQueryApplicationClass() { | ||||
| return 'PhabricatorPeopleApplication'; | return 'PhabricatorPeopleApplication'; | ||||
| } | } | ||||
| /** | |||||
| * Attempts to find an external account and if none exists creates a new | |||||
| * external account with a shiny new ID and PHID. | |||||
| * | |||||
| * NOTE: This function assumes the first item in various query parameters is | |||||
| * the correct value to use in creating a new external account. | |||||
| */ | |||||
| public function loadOneOrCreate() { | |||||
| $account = $this->executeOne(); | |||||
| if (!$account) { | |||||
| $account = new PhabricatorExternalAccount(); | |||||
| if ($this->accountIDs) { | |||||
| $account->setAccountID(reset($this->accountIDs)); | |||||
| } | |||||
| if ($this->accountTypes) { | |||||
| $account->setAccountType(reset($this->accountTypes)); | |||||
| } | |||||
| if ($this->accountDomains) { | |||||
| $account->setAccountDomain(reset($this->accountDomains)); | |||||
| } | |||||
| if ($this->accountSecrets) { | |||||
| $account->setAccountSecret(reset($this->accountSecrets)); | |||||
| } | |||||
| if ($this->userPHIDs) { | |||||
| $account->setUserPHID(reset($this->userPHIDs)); | |||||
| } | |||||
| $account->save(); | |||||
| } | |||||
| return $account; | |||||
| } | |||||
| } | } | ||||