Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / fund / xaction / FundInitiativeMerchantTransaction.php
blob82bd6b5bf4cea91b20c3fa1a7c9080db2f490e94
1 <?php
3 final class FundInitiativeMerchantTransaction
4 extends FundInitiativeTransactionType {
6 const TRANSACTIONTYPE = 'fund:merchant';
8 public function generateOldValue($object) {
9 return $object->getMerchantPHID();
12 public function applyInternalEffects($object, $value) {
13 $object->setMerchantPHID($value);
16 public function getTitle() {
17 $new = $this->getNewValue();
18 $new_merchant = $this->renderHandleList(array($new));
20 $old = $this->getOldValue();
21 $old_merchant = $this->renderHandleList(array($old));
23 if ($old) {
24 return pht(
25 '%s changed the merchant receiving funds from this '.
26 'initiative from %s to %s.',
27 $this->renderAuthor(),
28 $old_merchant,
29 $new_merchant);
30 } else {
31 return pht(
32 '%s set the merchant receiving funds from this '.
33 'initiative to %s.',
34 $this->renderAuthor(),
35 $new_merchant);
39 public function getTitleForFeed() {
40 $new = $this->getNewValue();
41 $new_merchant = $this->renderHandleList(array($new));
43 $old = $this->getOldValue();
44 $old_merchant = $this->renderHandleList(array($old));
46 return pht(
47 '%s changed the merchant receiving funds from %s '.
48 'from %s to %s.',
49 $this->renderAuthor(),
50 $this->renderObject(),
51 $old_merchant,
52 $new_merchant);
55 public function validateTransactions($object, array $xactions) {
56 $errors = array();
58 if ($this->isEmptyTextTransaction($object->getMerchantPHID(), $xactions)) {
59 $errors[] = $this->newRequiredError(
60 pht('Initiatives must have a payable merchant.'));
63 foreach ($xactions as $xaction) {
64 $merchant_phid = $xaction->getNewValue();
66 // Make sure the actor has permission to edit the merchant they're
67 // selecting. You aren't allowed to send payments to an account you
68 // do not control.
69 $merchants = id(new PhortuneMerchantQuery())
70 ->setViewer($this->getActor())
71 ->withPHIDs(array($merchant_phid))
72 ->requireCapabilities(
73 array(
74 PhabricatorPolicyCapability::CAN_VIEW,
75 PhabricatorPolicyCapability::CAN_EDIT,
77 ->execute();
78 if (!$merchants) {
79 $errors[] = $this->newInvalidError(
80 pht('You must specify a merchant account you control as the '.
81 'recipient of funds from this initiative.'));
85 return $errors;
88 public function getIcon() {
89 return 'fa-bank';