Remove product literal strings in "pht()", part 18
[phabricator.git] / src / applications / auth / xaction / PhabricatorAuthContactNumberPrimaryTransaction.php
blob42788029b5ea0d89a5b943296b3bfb0be1f04748
1 <?php
3 final class PhabricatorAuthContactNumberPrimaryTransaction
4 extends PhabricatorAuthContactNumberTransactionType {
6 const TRANSACTIONTYPE = 'primary';
8 public function generateOldValue($object) {
9 return (bool)$object->getIsPrimary();
12 public function applyInternalEffects($object, $value) {
13 $object->setIsPrimary((int)$value);
16 public function getTitle() {
17 return pht(
18 '%s made this the primary contact number.',
19 $this->renderAuthor());
22 public function validateTransactions($object, array $xactions) {
23 $errors = array();
25 foreach ($xactions as $xaction) {
26 $new_value = $xaction->getNewValue();
28 if (!$new_value) {
29 $errors[] = $this->newInvalidError(
30 pht(
31 'To choose a different primary contact number, make that '.
32 'number primary (instead of trying to demote this one).'),
33 $xaction);
34 continue;
37 if ($object->isDisabled()) {
38 $errors[] = $this->newInvalidError(
39 pht(
40 'You can not make a disabled number a primary contact number.'),
41 $xaction);
42 continue;
45 $mfa_error = $this->newContactNumberMFAError($object, $xaction);
46 if ($mfa_error) {
47 $errors[] = $mfa_error;
48 continue;
52 return $errors;