Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / phortune / xaction / PhortuneMerchantInvoiceEmailTransaction.php
blobd58167de25d963e63dea11ddbc531057bb77d903
1 <?php
3 final class PhortuneMerchantInvoiceEmailTransaction
4 extends PhortuneMerchantTransactionType {
6 const TRANSACTIONTYPE = 'merchant:invoiceemail';
8 public function generateOldValue($object) {
9 return $object->getInvoiceEmail();
12 public function applyInternalEffects($object, $value) {
13 $object->setInvoiceEmail($value);
16 public function getTitle() {
17 $old = $this->getOldValue();
18 $new = $this->getNewValue();
20 if (strlen($old) && strlen($new)) {
21 return pht(
22 '%s updated the invoice email from %s to %s.',
23 $this->renderAuthor(),
24 $this->renderOldValue(),
25 $this->renderNewValue());
26 } else if (strlen($old)) {
27 return pht(
28 '%s removed the invoice email.',
29 $this->renderAuthor());
30 } else {
31 return pht(
32 '%s set the invoice email to %s.',
33 $this->renderAuthor(),
34 $this->renderNewValue());
38 public function getTitleForFeed() {
39 $old = $this->getOldValue();
40 $new = $this->getNewValue();
42 if (strlen($old) && strlen($new)) {
43 return pht(
44 '%s updated %s invoice email from %s to %s.',
45 $this->renderAuthor(),
46 $this->renderObject(),
47 $this->renderOldValue(),
48 $this->renderNewValue());
49 } else if (strlen($old)) {
50 return pht(
51 '%s removed the invoice email for %s.',
52 $this->renderAuthor(),
53 $this->renderObject());
54 } else {
55 return pht(
56 '%s set the invoice email for %s to %s.',
57 $this->renderAuthor(),
58 $this->renderObject(),
59 $this->renderNewValue());
63 public function getIcon() {
64 return 'fa-envelope';
67 public function validateTransactions($object, array $xactions) {
68 $errors = array();
70 $max_length = $object->getColumnMaximumByteLength('invoiceEmail');
71 foreach ($xactions as $xaction) {
72 if (strlen($xaction->getNewValue())) {
73 $email = new PhutilEmailAddress($xaction->getNewValue());
74 $domain = $email->getDomainName();
75 if (!strlen($domain)) {
76 $errors[] = $this->newInvalidError(
77 pht('Invoice email "%s" must be a valid email.',
78 $xaction->getNewValue()));
81 $new_value = $xaction->getNewValue();
82 $new_length = strlen($new_value);
83 if ($new_length > $max_length) {
84 $errors[] = $this->newInvalidError(
85 pht('The email can be no longer than %s characters.',
86 new PhutilNumber($max_length)));
91 return $errors;