Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / phortune / product / PhortuneSubscriptionProduct.php
blob85eb2999c7d0c9011b759b1b34607c216ab9850b
1 <?php
3 final class PhortuneSubscriptionProduct
4 extends PhortuneProductImplementation {
6 private $viewer;
7 private $subscriptionPHID;
8 private $subscription;
10 public function setSubscriptionPHID($subscription_phid) {
11 $this->subscriptionPHID = $subscription_phid;
12 return $this;
15 public function getSubscriptionPHID() {
16 return $this->subscriptionPHID;
19 public function setSubscription(PhortuneSubscription $subscription) {
20 $this->subscription = $subscription;
21 return $this;
24 public function getSubscription() {
25 return $this->subscription;
28 public function setViewer(PhabricatorUser $viewer) {
29 $this->viewer = $viewer;
30 return $this;
33 public function getViewer() {
34 return $this->viewer;
37 public function getRef() {
38 return $this->getSubscriptionPHID();
41 public function getName(PhortuneProduct $product) {
42 return $this->getSubscription()->getSubscriptionName();
45 public function getPriceAsCurrency(PhortuneProduct $product) {
46 // Prices are calculated by the SubscriptionImplementation.
47 return PhortuneCurrency::newEmptyCurrency();
50 public function didPurchaseProduct(
51 PhortuneProduct $product,
52 PhortunePurchase $purchase) {
53 return $this->getSubscription()->didPurchaseProduct(
54 $product,
55 $purchase);
58 public function didRefundProduct(
59 PhortuneProduct $product,
60 PhortunePurchase $purchase,
61 PhortuneCurrency $amount) {
62 // TODO: Callback the subscription.
63 return;
66 public function getPurchaseName(
67 PhortuneProduct $product,
68 PhortunePurchase $purchase) {
69 return $this->getSubscription()->getPurchaseName(
70 $product,
71 $purchase);
74 public function getPurchaseURI(
75 PhortuneProduct $product,
76 PhortunePurchase $purchase) {
77 return $this->getSubscription()->getPurchaseURI(
78 $product,
79 $purchase);
82 public function loadImplementationsForRefs(
83 PhabricatorUser $viewer,
84 array $refs) {
86 $subscriptions = id(new PhortuneSubscriptionQuery())
87 ->setViewer($viewer)
88 ->withPHIDs($refs)
89 ->execute();
90 $subscriptions = mpull($subscriptions, null, 'getPHID');
92 $objects = array();
93 foreach ($refs as $ref) {
94 $subscription = idx($subscriptions, $ref);
95 if (!$subscription) {
96 continue;
99 $objects[] = id(new PhortuneSubscriptionProduct())
100 ->setViewer($viewer)
101 ->setSubscriptionPHID($ref)
102 ->setSubscription($subscription);
105 return $objects;