Path: blob/master/src/applications/packages/xaction/version/PhabricatorPackagesVersionNameTransaction.php
12242 views
<?php12final class PhabricatorPackagesVersionNameTransaction3extends PhabricatorPackagesVersionTransactionType {45const TRANSACTIONTYPE = 'packages.version.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 changed the name of this version from %s to %s.',18$this->renderAuthor(),19$this->renderOldValue(),20$this->renderNewValue());21}2223public function getTitleForFeed() {24return pht(25'%s updated the name for %s from %s to %s.',26$this->renderAuthor(),27$this->renderObject(),28$this->renderOldValue(),29$this->renderNewValue());30}3132public function validateTransactions($object, array $xactions) {33$errors = array();3435if ($this->isEmptyTextTransaction($object->getName(), $xactions)) {36$errors[] = $this->newRequiredError(37pht('Versions must have a name.'));38return $errors;39}4041foreach ($xactions as $xaction) {42$value = $xaction->getNewValue();43try {44PhabricatorPackagesVersion::assertValidVersionName($value);45} catch (Exception $ex) {46$errors[] = $this->newInvalidError($ex->getMessage(), $xaction);47}48}4950if (!$this->isNewObject()) {51foreach ($xactions as $xaction) {52$errors[] = $this->newInvalidError(53pht('Once a version is created, its name can not be changed.'),54$xaction);55}56}5758return $errors;59}6061}626364