3 final class PhabricatorAuthContactNumberStatusTransaction
4 extends PhabricatorAuthContactNumberTransactionType
{
6 const TRANSACTIONTYPE
= 'status';
8 public function generateOldValue($object) {
9 return $object->getStatus();
12 public function applyInternalEffects($object, $value) {
13 $object->setStatus($value);
16 public function getTitle() {
17 $new = $this->getNewValue();
19 if ($new === PhabricatorAuthContactNumber
::STATUS_DISABLED
) {
21 '%s disabled this contact number.',
22 $this->renderAuthor());
25 '%s enabled this contact number.',
26 $this->renderAuthor());
30 public function validateTransactions($object, array $xactions) {
33 $map = PhabricatorAuthContactNumber
::getStatusNameMap();
35 foreach ($xactions as $xaction) {
36 $new_value = $xaction->getNewValue();
38 if (!isset($map[$new_value])) {
39 $errors[] = $this->newInvalidError(
41 'Status ("%s") is not a valid contact number status. Valid '.
42 'status constants are: %s.',
44 implode(', ', array_keys($map))),
49 $mfa_error = $this->newContactNumberMFAError($object, $xaction);
51 $errors[] = $mfa_error;
55 // NOTE: Enabling a contact number may cause us to collide with another
56 // active contact number. However, there might also be a transaction in
57 // this group that changes the number itself. Since we can't easily
58 // predict if we'll collide or not, just let the duplicate key logic
59 // handle it when we do.