Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / files / xaction / PhabricatorFileNameTransaction.php
blob7eb9396b6654f31a773d8e0d958cb4442e6e5874
1 <?php
3 final class PhabricatorFileNameTransaction
4 extends PhabricatorFileTransactionType {
6 const TRANSACTIONTYPE = 'file:name';
8 public function generateOldValue($object) {
9 return $object->getName();
12 public function applyInternalEffects($object, $value) {
13 $object->setName($value);
16 public function getTitle() {
17 return pht(
18 '%s updated the name for this file from "%s" to "%s".',
19 $this->renderAuthor(),
20 $this->renderOldValue(),
21 $this->renderNewValue());
24 public function getTitleForFeed() {
25 return pht(
26 '%s updated the name of %s from "%s" to "%s".',
27 $this->renderAuthor(),
28 $this->renderObject(),
29 $this->renderOldValue(),
30 $this->renderNewValue());
33 public function validateTransactions($object, array $xactions) {
34 $errors = array();
36 if ($this->isEmptyTextTransaction($object->getName(), $xactions)) {
37 $errors[] = $this->newRequiredError(pht('Files must have a name.'));
40 $max_length = $object->getColumnMaximumByteLength('name');
41 foreach ($xactions as $xaction) {
42 $new_value = $xaction->getNewValue();
43 $new_length = strlen($new_value);
44 if ($new_length > $max_length) {
45 $errors[] = $this->newInvalidError(
46 pht(
47 'File names must not be longer than %s character(s).',
48 new PhutilNumber($max_length)));
52 return $errors;