Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / phortune / storage / PhortuneMerchant.php
blob6e0bf81e22c1ebee06bba9adf45f04d88965cbdd
1 <?php
3 final class PhortuneMerchant extends PhortuneDAO
4 implements
5 PhabricatorApplicationTransactionInterface,
6 PhabricatorPolicyInterface {
8 protected $name;
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())
21 ->setContactInfo('')
22 ->setInvoiceEmail('')
23 ->setInvoiceFooter('');
26 protected function getConfiguration() {
27 return array(
28 self::CONFIG_AUX_PHID => true,
29 self::CONFIG_COLUMN_SCHEMA => array(
30 'name' => 'text255',
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;
51 return $this;
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;
64 return $this;
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() {
76 return urisprintf(
77 '/phortune/merchant/%d/details/',
78 $this->getID());
81 public function getOrdersURI() {
82 return urisprintf(
83 '/phortune/merchant/%d/orders/',
84 $this->getID());
87 public function getOrderListURI($path = '') {
88 return urisprintf(
89 '/phortune/merchant/%d/orders/list/%s',
90 $this->getID(),
91 $path);
94 public function getSubscriptionsURI() {
95 return urisprintf(
96 '/phortune/merchant/%d/subscriptions/',
97 $this->getID());
100 public function getSubscriptionListURI($path = '') {
101 return urisprintf(
102 '/phortune/merchant/%d/subscriptions/list/%s',
103 $this->getID(),
104 $path);
107 public function getManagersURI() {
108 return urisprintf(
109 '/phortune/merchant/%d/managers/',
110 $this->getID());
113 public function getPaymentProvidersURI() {
114 return urisprintf(
115 '/phortune/merchant/%d/providers/',
116 $this->getID());
119 /* -( PhabricatorApplicationTransactionInterface )------------------------- */
122 public function getApplicationTransactionEditor() {
123 return new PhortuneMerchantEditor();
126 public function getApplicationTransactionTemplate() {
127 return new PhortuneMerchantTransaction();
131 /* -( PhabricatorPolicyInterface )----------------------------------------- */
134 public function getCapabilities() {
135 return array(
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()])) {
153 return true;
156 return false;
159 public function describeAutomaticCapability($capability) {
160 return pht("A merchant's members an always view and edit it.");