Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / phortune / xaction / PhortuneAccountBillingNameTransaction.php
blob6c2cde6c9bbecf819026a5eae01c691c648753e1
1 <?php
3 final class PhortuneAccountBillingNameTransaction
4 extends PhortuneAccountTransactionType {
6 const TRANSACTIONTYPE = 'billing-name';
8 public function generateOldValue($object) {
9 return $object->getBillingName();
12 public function applyInternalEffects($object, $value) {
13 $object->setBillingName($value);
16 public function getTitle() {
17 $old = $this->getOldValue();
18 $new = $this->getNewValue();
20 if (strlen($old) && strlen($new)) {
21 return pht(
22 '%s changed the billing name for this account 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 billing name for this account (was %s).',
29 $this->renderAuthor(),
30 $this->renderOldValue());
31 } else {
32 return pht(
33 '%s set the billing name for this account to %s.',
34 $this->renderAuthor(),
35 $this->renderNewValue());
39 public function validateTransactions($object, array $xactions) {
40 $errors = array();
42 $max_length = $object->getColumnMaximumByteLength('billingName');
43 foreach ($xactions as $xaction) {
44 $new_value = $xaction->getNewValue();
45 $new_length = strlen($new_value);
46 if ($new_length > $max_length) {
47 $errors[] = $this->newRequiredError(
48 pht('The billing name can be no longer than %s characters.',
49 new PhutilNumber($max_length)));
53 return $errors;