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();
20 '%s created this initiative.',
21 $this->renderAuthor());
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();
35 '%s created initiative %s.',
36 $this->renderAuthor(),
37 $this->renderObject());
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) {
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)));