Path: blob/master/src/applications/nuance/xaction/NuanceSourceNameTransaction.php
12256 views
<?php12final class NuanceSourceNameTransaction3extends NuanceSourceTransactionType {45const TRANSACTIONTYPE = 'source.name';67public function generateOldValue($object) {8return $object->getName();9}1011public function applyInternalEffects($object, $value) {12$object->setName($value);13}1415public function getTitle() {16return pht(17'%s renamed this source from %s to %s.',18$this->renderAuthor(),19$this->renderOldValue(),20$this->renderNewValue());21}2223public function validateTransactions($object, array $xactions) {24$errors = array();2526if ($this->isEmptyTextTransaction($object->getName(), $xactions)) {27$errors[] = $this->newRequiredError(28pht('Sources must have a name.'));29}3031$max_length = $object->getColumnMaximumByteLength('name');32foreach ($xactions as $xaction) {33$new_value = $xaction->getNewValue();34$new_length = strlen($new_value);35if ($new_length > $max_length) {36$errors[] = $this->newInvalidError(37pht(38'Source names must not be longer than %s character(s).',39new PhutilNumber($max_length)));40}41}4243return $errors;44}4546}474849