Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / fund / xaction / FundInitiativeNameTransaction.php
blob4a47c20a17cf74f68a0aeafe6f46d5ea165fac68
1 <?php
3 final class FundInitiativeNameTransaction
4 extends FundInitiativeTransactionType {
6 const TRANSACTIONTYPE = 'fund: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 if (!strlen($old)) {
19 return pht(
20 '%s created this initiative.',
21 $this->renderAuthor());
22 } else {
23 return pht(
24 '%s renamed this initiative from %s to %s.',
25 $this->renderAuthor(),
26 $this->renderOldValue(),
27 $this->renderNewValue());
31 public function getTitleForFeed() {
32 $old = $this->getOldValue();
33 if (!strlen($old)) {
34 return pht(
35 '%s created initiative %s.',
36 $this->renderAuthor(),
37 $this->renderObject());
38 } else {
39 return pht(
40 '%s renamed %s from %s to %s.',
41 $this->renderAuthor(),
42 $this->renderObject(),
43 $this->renderOldValue(),
44 $this->renderNewValue());
48 public function validateTransactions($object, array $xactions) {
49 $errors = array();
51 if ($this->isEmptyTextTransaction($object->getName(), $xactions)) {
52 $errors[] = $this->newRequiredError(
53 pht('Initiatives must have a name.'));
56 $max_length = $object->getColumnMaximumByteLength('name');
57 foreach ($xactions as $xaction) {
58 $new_value = $xaction->getNewValue();
59 $new_length = strlen($new_value);
60 if ($new_length > $max_length) {
61 $errors[] = $this->newInvalidError(
62 pht('The name can be no longer than %s characters.',
63 new PhutilNumber($max_length)));
67 return $errors;