Path: blob/master/src/applications/drydock/xaction/DrydockBlueprintNameTransaction.php
12256 views
<?php12final class DrydockBlueprintNameTransaction3extends DrydockBlueprintTransactionType {45const TRANSACTIONTYPE = 'drydock:blueprint:name';67public function generateOldValue($object) {8return $object->getBlueprintName();9}1011public function applyInternalEffects($object, $value) {12$object->setBlueprintName($value);13}1415public function getTitle() {16return pht(17'%s renamed this blueprint from %s to %s.',18$this->renderAuthor(),19$this->renderOldValue(),20$this->renderNewValue());21}2223public function getTitleForFeed() {24$old = $this->getOldValue();25$new = $this->getNewValue();2627return pht(28'%s renamed %s from %s to %s.',29$this->renderAuthor(),30$this->renderObject(),31$this->renderOldValue(),32$this->renderNewValue());33}3435public function validateTransactions($object, array $xactions) {36$errors = array();3738$name = $object->getBlueprintName();39if ($this->isEmptyTextTransaction($name, $xactions)) {40$errors[] = $this->newRequiredError(41pht('Blueprints must have a name.'));42}4344$max_length = $object->getColumnMaximumByteLength('blueprintName');45foreach ($xactions as $xaction) {46$new_value = $xaction->getNewValue();4748$new_length = strlen($new_value);49if ($new_length > $max_length) {50$errors[] = $this->newInvalidError(51pht('Blueprint names can be no longer than %s characters.',52new PhutilNumber($max_length)));53}54}5556return $errors;57}5859}606162