Path: blob/master/src/applications/fund/xaction/FundInitiativeNameTransaction.php
12256 views
<?php12final class FundInitiativeNameTransaction3extends FundInitiativeTransactionType {45const TRANSACTIONTYPE = 'fund:name';67public function generateOldValue($object) {8return $object->getName();9}1011public function applyInternalEffects($object, $value) {12$object->setName($value);13}1415public function getTitle() {16$old = $this->getOldValue();17if (!strlen($old)) {18return pht(19'%s created this initiative.',20$this->renderAuthor());21} else {22return pht(23'%s renamed this initiative from %s to %s.',24$this->renderAuthor(),25$this->renderOldValue(),26$this->renderNewValue());27}28}2930public function getTitleForFeed() {31$old = $this->getOldValue();32if (!strlen($old)) {33return pht(34'%s created initiative %s.',35$this->renderAuthor(),36$this->renderObject());37} else {38return pht(39'%s renamed %s from %s to %s.',40$this->renderAuthor(),41$this->renderObject(),42$this->renderOldValue(),43$this->renderNewValue());44}45}4647public function validateTransactions($object, array $xactions) {48$errors = array();4950if ($this->isEmptyTextTransaction($object->getName(), $xactions)) {51$errors[] = $this->newRequiredError(52pht('Initiatives must have a name.'));53}5455$max_length = $object->getColumnMaximumByteLength('name');56foreach ($xactions as $xaction) {57$new_value = $xaction->getNewValue();58$new_length = strlen($new_value);59if ($new_length > $max_length) {60$errors[] = $this->newInvalidError(61pht('The name can be no longer than %s characters.',62new PhutilNumber($max_length)));63}64}6566return $errors;67}686970}717273