Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / phortune / xaction / PhortuneAccountEmailAddressTransaction.php
blob87e6bb87e43d18b907dbf03c382958c94f42f09a
1 <?php
3 final class PhortuneAccountEmailAddressTransaction
4 extends PhortuneAccountEmailTransactionType {
6 const TRANSACTIONTYPE = 'address';
8 public function generateOldValue($object) {
9 return $object->getAddress();
12 public function applyInternalEffects($object, $value) {
13 $object->setAddress($value);
16 public function validateTransactions($object, array $xactions) {
17 $errors = array();
19 if ($this->isEmptyTextTransaction($object->getAddress(), $xactions)) {
20 $errors[] = $this->newRequiredError(
21 pht('You must provide an email address.'));
24 $max_length = $object->getColumnMaximumByteLength('address');
25 foreach ($xactions as $xaction) {
26 $old_value = $xaction->getOldValue();
27 $new_value = $xaction->getNewValue();
29 $new_length = strlen($new_value);
30 if ($new_length > $max_length) {
31 $errors[] = $this->newInvalidError(
32 pht(
33 'The address can be no longer than %s characters.',
34 new PhutilNumber($max_length)),
35 $xaction);
36 continue;
39 if (!PhabricatorUserEmail::isValidAddress($new_value)) {
40 $errors[] = $this->newInvalidError(
41 PhabricatorUserEmail::describeValidAddresses(),
42 $xaction);
43 continue;
46 if ($new_value !== $old_value) {
47 if (!$this->isNewObject()) {
48 $errors[] = $this->newInvalidError(
49 pht(
50 'Account email addresses can not be edited once they are '.
51 'created. To change the billing address for an account, '.
52 'disable the old address and then add a new address.'),
53 $xaction);
54 continue;
60 return $errors;