Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phortune/storage/PhortuneAccount.php
Show All 10 Lines | implements | ||||
PhabricatorApplicationTransactionInterface, | PhabricatorApplicationTransactionInterface, | ||||
PhabricatorPolicyInterface { | PhabricatorPolicyInterface { | ||||
protected $name; | protected $name; | ||||
protected $billingName; | protected $billingName; | ||||
protected $billingAddress; | protected $billingAddress; | ||||
private $memberPHIDs = self::ATTACHABLE; | private $memberPHIDs = self::ATTACHABLE; | ||||
private $merchantPHIDs = self::ATTACHABLE; | |||||
public static function initializeNewAccount(PhabricatorUser $actor) { | public static function initializeNewAccount(PhabricatorUser $actor) { | ||||
return id(new self()) | return id(new self()) | ||||
->setBillingName('') | ->setBillingName('') | ||||
->setBillingAddress('') | ->setBillingAddress('') | ||||
->attachMerchantPHIDs(array()) | |||||
->attachMemberPHIDs(array()); | ->attachMemberPHIDs(array()); | ||||
} | } | ||||
public static function createNewAccount( | public static function createNewAccount( | ||||
PhabricatorUser $actor, | PhabricatorUser $actor, | ||||
PhabricatorContentSource $content_source) { | PhabricatorContentSource $content_source) { | ||||
$account = self::initializeNewAccount($actor); | $account = self::initializeNewAccount($actor); | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | final class PhortuneAccount extends PhortuneDAO | ||||
} | } | ||||
public function getEmailAddressesURI() { | public function getEmailAddressesURI() { | ||||
return urisprintf( | return urisprintf( | ||||
'/phortune/account/%d/addresses/', | '/phortune/account/%d/addresses/', | ||||
$this->getID()); | $this->getID()); | ||||
} | } | ||||
public function attachMerchantPHIDs(array $merchant_phids) { | |||||
$this->merchantPHIDs = $merchant_phids; | |||||
return $this; | |||||
} | |||||
public function getMerchantPHIDs() { | |||||
return $this->assertAttached($this->merchantPHIDs); | |||||
} | |||||
public function writeMerchantEdge(PhortuneMerchant $merchant) { | |||||
$edge_src = $this->getPHID(); | |||||
$edge_type = PhortuneAccountHasMerchantEdgeType::EDGECONST; | |||||
$edge_dst = $merchant->getPHID(); | |||||
id(new PhabricatorEdgeEditor()) | |||||
->addEdge($edge_src, $edge_type, $edge_dst) | |||||
->save(); | |||||
return $this; | |||||
} | |||||
/* -( PhabricatorApplicationTransactionInterface )------------------------- */ | /* -( PhabricatorApplicationTransactionInterface )------------------------- */ | ||||
public function getApplicationTransactionEditor() { | public function getApplicationTransactionEditor() { | ||||
return new PhortuneAccountEditor(); | return new PhortuneAccountEditor(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines |