Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / auth / xaction / PhabricatorAuthFactorProviderNameTransaction.php
blob9a04d561005666f946901d4018553848fd71fe35
1 <?php
3 final class PhabricatorAuthFactorProviderNameTransaction
4 extends PhabricatorAuthFactorProviderTransactionType {
6 const TRANSACTIONTYPE = '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 $old = $this->getOldValue();
18 $new = $this->getNewValue();
20 if (!strlen($old)) {
21 return pht(
22 '%s named this provider %s.',
23 $this->renderAuthor(),
24 $this->renderNewValue());
25 } else if (!strlen($new)) {
26 return pht(
27 '%s removed the name (%s) of this provider.',
28 $this->renderAuthor(),
29 $this->renderOldValue());
30 } else {
31 return pht(
32 '%s renamed this provider from %s to %s.',
33 $this->renderAuthor(),
34 $this->renderOldValue(),
35 $this->renderNewValue());
39 public function validateTransactions($object, array $xactions) {
40 $errors = array();
42 $max_length = $object->getColumnMaximumByteLength('name');
43 foreach ($xactions as $xaction) {
44 $new_value = $xaction->getNewValue();
45 $new_length = strlen($new_value);
46 if ($new_length > $max_length) {
47 $errors[] = $this->newInvalidError(
48 pht(
49 'Provider names can not be longer than %s characters.',
50 new PhutilNumber($max_length)),
51 $xaction);
55 return $errors;
58 public function getTransactionTypeForConduit($xaction) {
59 return 'name';
62 public function getFieldValuesForConduit($xaction, $data) {
63 return array(
64 'old' => $xaction->getOldValue(),
65 'new' => $xaction->getNewValue(),