Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / spaces / xaction / PhabricatorSpacesNamespaceNameTransaction.php
blobd7fcbc2c7a07f864c37fb3a8e22fe46e8cfaa013
1 <?php
3 final class PhabricatorSpacesNamespaceNameTransaction
4 extends PhabricatorSpacesNamespaceTransactionType {
6 const TRANSACTIONTYPE = 'spaces:name';
8 public function generateOldValue($object) {
9 return $object->getNamespaceName();
12 public function applyInternalEffects($object, $value) {
13 $object->setNamespaceName($value);
16 public function getTitle() {
17 $old = $this->getOldValue();
18 if (!strlen($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());
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());
40 public function validateTransactions($object, array $xactions) {
41 $errors = array();
43 if ($this->isEmptyTextTransaction($object->getNamespaceName(), $xactions)) {
44 $errors[] = $this->newRequiredError(
45 pht('Spaces must have a name.'));
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)));
59 return $errors;