3 final class PhortuneMerchant
extends PhortuneDAO
5 PhabricatorApplicationTransactionInterface
,
6 PhabricatorPolicyInterface
{
9 protected $description;
10 protected $contactInfo;
11 protected $invoiceEmail;
12 protected $invoiceFooter;
13 protected $profileImagePHID;
15 private $memberPHIDs = self
::ATTACHABLE
;
16 private $profileImageFile = self
::ATTACHABLE
;
18 public static function initializeNewMerchant(PhabricatorUser
$actor) {
19 return id(new PhortuneMerchant())
20 ->attachMemberPHIDs(array())
23 ->setInvoiceFooter('');
26 protected function getConfiguration() {
28 self
::CONFIG_AUX_PHID
=> true,
29 self
::CONFIG_COLUMN_SCHEMA
=> array(
31 'description' => 'text',
32 'contactInfo' => 'text',
33 'invoiceEmail' => 'text255',
34 'invoiceFooter' => 'text',
35 'profileImagePHID' => 'phid?',
37 ) + parent
::getConfiguration();
40 public function generatePHID() {
41 return PhabricatorPHID
::generateNewPHID(
42 PhortuneMerchantPHIDType
::TYPECONST
);
45 public function getMemberPHIDs() {
46 return $this->assertAttached($this->memberPHIDs
);
49 public function attachMemberPHIDs(array $member_phids) {
50 $this->memberPHIDs
= $member_phids;
54 public function getURI() {
55 return '/phortune/merchant/'.$this->getID().'/';
58 public function getProfileImageURI() {
59 return $this->getProfileImageFile()->getBestURI();
62 public function attachProfileImageFile(PhabricatorFile
$file) {
63 $this->profileImageFile
= $file;
67 public function getProfileImageFile() {
68 return $this->assertAttached($this->profileImageFile
);
71 public function getObjectName() {
72 return pht('Merchant %d', $this->getID());
75 public function getDetailsURI() {
77 '/phortune/merchant/%d/details/',
81 public function getOrdersURI() {
83 '/phortune/merchant/%d/orders/',
87 public function getOrderListURI($path = '') {
89 '/phortune/merchant/%d/orders/list/%s',
94 public function getSubscriptionsURI() {
96 '/phortune/merchant/%d/subscriptions/',
100 public function getSubscriptionListURI($path = '') {
102 '/phortune/merchant/%d/subscriptions/list/%s',
107 public function getManagersURI() {
109 '/phortune/merchant/%d/managers/',
113 public function getPaymentProvidersURI() {
115 '/phortune/merchant/%d/providers/',
119 /* -( PhabricatorApplicationTransactionInterface )------------------------- */
122 public function getApplicationTransactionEditor() {
123 return new PhortuneMerchantEditor();
126 public function getApplicationTransactionTemplate() {
127 return new PhortuneMerchantTransaction();
131 /* -( PhabricatorPolicyInterface )----------------------------------------- */
134 public function getCapabilities() {
136 PhabricatorPolicyCapability
::CAN_VIEW
,
137 PhabricatorPolicyCapability
::CAN_EDIT
,
141 public function getPolicy($capability) {
142 switch ($capability) {
143 case PhabricatorPolicyCapability
::CAN_VIEW
:
144 return PhabricatorPolicies
::getMostOpenPolicy();
145 case PhabricatorPolicyCapability
::CAN_EDIT
:
146 return PhabricatorPolicies
::POLICY_NOONE
;
150 public function hasAutomaticCapability($capability, PhabricatorUser
$viewer) {
151 $members = array_fuse($this->getMemberPHIDs());
152 if (isset($members[$viewer->getPHID()])) {
159 public function describeAutomaticCapability($capability) {
160 return pht("A merchant's members an always view and edit it.");