@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorSpacesNamespaceNameTransaction
4 extends PhabricatorSpacesNamespaceTransactionType {
5
6 const TRANSACTIONTYPE = 'spaces:name';
7
8 public function generateOldValue($object) {
9 return $object->getNamespaceName();
10 }
11
12 public function applyInternalEffects($object, $value) {
13 $object->setNamespaceName($value);
14 }
15
16 public function getTitle() {
17 $old = $this->getOldValue();
18 if (!phutil_nonempty_string($old)) {
19 return pht(
20 '%s created this space.',
21 $this->renderAuthor());
22 } else {
23 return pht(
24 '%s renamed this space from %s to %s.',
25 $this->renderAuthor(),
26 $this->renderOldValue(),
27 $this->renderNewValue());
28 }
29 }
30
31 public function getTitleForFeed() {
32 return pht(
33 '%s renamed space %s from %s to %s.',
34 $this->renderAuthor(),
35 $this->renderObject(),
36 $this->renderOldValue(),
37 $this->renderNewValue());
38 }
39
40 public function validateTransactions($object, array $xactions) {
41 $errors = array();
42
43 if ($this->isEmptyTextTransaction($object->getNamespaceName(), $xactions)) {
44 $errors[] = $this->newRequiredError(
45 pht('Spaces must have a name.'));
46 }
47
48 $max_length = $object->getColumnMaximumByteLength('namespaceName');
49 foreach ($xactions as $xaction) {
50 $new_value = $xaction->getNewValue();
51 $new_length = strlen($new_value);
52 if ($new_length > $max_length) {
53 $errors[] = $this->newInvalidError(
54 pht('The name can be no longer than %s characters.',
55 new PhutilNumber($max_length)));
56 }
57 }
58
59 return $errors;
60 }
61
62}