Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / phortune / xaction / PhortuneMerchantNameTransaction.php
blobb0115ace3e71ec04bd8b38ee12524b9f2a0977d8
1 <?php
3 final class PhortuneMerchantNameTransaction
4 extends PhortuneMerchantTransactionType {
6 const TRANSACTIONTYPE = 'merchant:name';
8 public function generateOldValue($object) {
9 return $object->getName();
12 public function applyInternalEffects($object, $value) {
13 $object->setName($value);
16 public function getTitle() {
17 return pht(
18 '%s renamed this merchant from %s to %s.',
19 $this->renderAuthor(),
20 $this->renderOldValue(),
21 $this->renderNewValue());
24 public function getTitleForFeed() {
25 return pht(
26 '%s renamed %s merchant name from %s to %s.',
27 $this->renderAuthor(),
28 $this->renderObject(),
29 $this->renderOldValue(),
30 $this->renderNewValue());
33 public function validateTransactions($object, array $xactions) {
34 $errors = array();
36 if ($this->isEmptyTextTransaction($object->getName(), $xactions)) {
37 $errors[] = $this->newRequiredError(
38 pht('Merchants must have a name.'));
41 $max_length = $object->getColumnMaximumByteLength('name');
42 foreach ($xactions as $xaction) {
43 $new_value = $xaction->getNewValue();
44 $new_length = strlen($new_value);
45 if ($new_length > $max_length) {
46 $errors[] = $this->newInvalidError(
47 pht('The name can be no longer than %s characters.',
48 new PhutilNumber($max_length)));
52 return $errors;