Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phortune/query/PhortuneAccountQuery.php
<?php | <?php | ||||
final class PhortuneAccountQuery | final class PhortuneAccountQuery | ||||
extends PhabricatorCursorPagedPolicyAwareQuery { | extends PhabricatorCursorPagedPolicyAwareQuery { | ||||
private $ids; | private $ids; | ||||
private $phids; | private $phids; | ||||
private $memberPHIDs; | private $memberPHIDs; | ||||
public static function loadAccountsForUser( | |||||
PhabricatorUser $user, | |||||
PhabricatorContentSource $content_source) { | |||||
$accounts = id(new PhortuneAccountQuery()) | |||||
->setViewer($user) | |||||
->withMemberPHIDs(array($user->getPHID())) | |||||
->execute(); | |||||
if (!$accounts) { | |||||
$accounts = array( | |||||
PhortuneAccount::createNewAccount($user, $content_source), | |||||
); | |||||
} | |||||
$accounts = mpull($accounts, null, 'getPHID'); | |||||
return $accounts; | |||||
} | |||||
public static function loadActiveAccountForUser( | public static function loadActiveAccountForUser( | ||||
PhabricatorUser $user, | PhabricatorUser $user, | ||||
PhabricatorContentSource $content_source) { | PhabricatorContentSource $content_source) { | ||||
$accounts = id(new PhortuneAccountQuery()) | $accounts = id(new PhortuneAccountQuery()) | ||||
->setViewer($user) | ->setViewer($user) | ||||
->withMemberPHIDs(array($user->getPHID())) | ->withMemberPHIDs(array($user->getPHID())) | ||||
->execute(); | ->execute(); | ||||
▲ Show 20 Lines • Show All 103 Lines • Show Last 20 Lines |