Path: blob/master/src/applications/auth/xaction/PhabricatorAuthContactNumberPrimaryTransaction.php
12256 views
<?php12final class PhabricatorAuthContactNumberPrimaryTransaction3extends PhabricatorAuthContactNumberTransactionType {45const TRANSACTIONTYPE = 'primary';67public function generateOldValue($object) {8return (bool)$object->getIsPrimary();9}1011public function applyInternalEffects($object, $value) {12$object->setIsPrimary((int)$value);13}1415public function getTitle() {16return pht(17'%s made this the primary contact number.',18$this->renderAuthor());19}2021public function validateTransactions($object, array $xactions) {22$errors = array();2324foreach ($xactions as $xaction) {25$new_value = $xaction->getNewValue();2627if (!$new_value) {28$errors[] = $this->newInvalidError(29pht(30'To choose a different primary contact number, make that '.31'number primary (instead of trying to demote this one).'),32$xaction);33continue;34}3536if ($object->isDisabled()) {37$errors[] = $this->newInvalidError(38pht(39'You can not make a disabled number a primary contact number.'),40$xaction);41continue;42}4344$mfa_error = $this->newContactNumberMFAError($object, $xaction);45if ($mfa_error) {46$errors[] = $mfa_error;47continue;48}49}5051return $errors;52}5354}555657