Path: blob/master/src/applications/herald/xaction/HeraldRuleNameTransaction.php
12256 views
<?php12final class HeraldRuleNameTransaction3extends HeraldRuleTransactionType {45const TRANSACTIONTYPE = 'herald: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 rule 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('Rules must have a name.'));29}3031$max_length = $object->getColumnMaximumByteLength('name');32foreach ($xactions as $xaction) {33$new_value = $xaction->getNewValue();3435$new_length = strlen($new_value);36if ($new_length > $max_length) {37$errors[] = $this->newInvalidError(38pht(39'Rule names can be no longer than %s characters.',40new PhutilNumber($max_length)));41}42}4344return $errors;45}4647}484950