Path: blob/master/src/applications/owners/xaction/PhabricatorOwnersPackageAuditingTransaction.php
12256 views
<?php12final class PhabricatorOwnersPackageAuditingTransaction3extends PhabricatorOwnersPackageTransactionType {45const TRANSACTIONTYPE = 'owners.auditing';67public function generateOldValue($object) {8return $object->getAuditingState();9}1011public function generateNewValue($object, $value) {12return PhabricatorOwnersAuditRule::getStorageValueFromAPIValue($value);13}1415public function applyInternalEffects($object, $value) {16$object->setAuditingState($value);17}1819public function getTitle() {20$old_value = $this->getOldValue();21$new_value = $this->getNewValue();2223$old_rule = PhabricatorOwnersAuditRule::newFromState($old_value);24$new_rule = PhabricatorOwnersAuditRule::newFromState($new_value);2526return pht(27'%s changed the audit rule for this package from %s to %s.',28$this->renderAuthor(),29$this->renderValue($old_rule->getDisplayName()),30$this->renderValue($new_rule->getDisplayName()));31}3233public function validateTransactions($object, array $xactions) {34$errors = array();3536// See PHI1047. This transaction type accepted some weird stuff. Continue37// supporting it for now, but move toward sensible consistency.3839$modern_options = PhabricatorOwnersAuditRule::getModernValueMap();40$deprecated_options = PhabricatorOwnersAuditRule::getDeprecatedValueMap();4142foreach ($xactions as $xaction) {43$new_value = $xaction->getNewValue();4445if (isset($modern_options[$new_value])) {46continue;47}4849if (isset($deprecated_options[$new_value])) {50continue;51}5253$errors[] = $this->newInvalidError(54pht(55'Package auditing value "%s" is not supported. Supported options '.56'are: %s. Deprecated options are: %s.',57$new_value,58implode(', ', $modern_options),59implode(', ', $deprecated_options)),60$xaction);61}6263return $errors;64}6566}676869