Path: blob/master/src/applications/files/xaction/PhabricatorFileNameTransaction.php
12241 views
<?php12final class PhabricatorFileNameTransaction3extends PhabricatorFileTransactionType {45const TRANSACTIONTYPE = 'file: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 updated the name for this file from "%s" to "%s".',18$this->renderAuthor(),19$this->renderOldValue(),20$this->renderNewValue());21}2223public function getTitleForFeed() {24return pht(25'%s updated the name of %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(pht('Files must have a name.'));37}3839$max_length = $object->getColumnMaximumByteLength('name');40foreach ($xactions as $xaction) {41$new_value = $xaction->getNewValue();42$new_length = strlen($new_value);43if ($new_length > $max_length) {44$errors[] = $this->newInvalidError(45pht(46'File names must not be longer than %s character(s).',47new PhutilNumber($max_length)));48}49}5051return $errors;52}5354}555657