Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / phortune / xaction / PhortuneAccountNameTransaction.php
blob08b8b694226d50bf60411b8373fcd7e515ce0744
1 <?php
3 final class PhortuneAccountNameTransaction
4 extends PhortuneAccountTransactionType {
6 const TRANSACTIONTYPE = 'phortune: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 $old = $this->getOldValue();
18 $new = $this->getNewValue();
20 if (strlen($old) && strlen($new)) {
21 return pht(
22 '%s renamed this account from %s to %s.',
23 $this->renderAuthor(),
24 $this->renderOldValue(),
25 $this->renderNewValue());
26 } else {
27 return pht(
28 '%s created this account.',
29 $this->renderAuthor());
33 public function validateTransactions($object, array $xactions) {
34 $errors = array();
36 if ($this->isEmptyTextTransaction($object->getName(), $xactions)) {
37 $errors[] = $this->newRequiredError(
38 pht('Accounts 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->newRequiredError(
47 pht('The name can be no longer than %s characters.',
48 new PhutilNumber($max_length)));
52 return $errors;