3 final class PhabricatorOwnersPackageAuthorityTransaction
4 extends PhabricatorOwnersPackageTransactionType
{
6 const TRANSACTIONTYPE
= 'owners.authority';
8 public function generateOldValue($object) {
9 return $object->getAuthorityMode();
12 public function validateTransactions($object, array $xactions) {
15 $map = PhabricatorOwnersPackage
::getAuthorityOptionsMap();
16 foreach ($xactions as $xaction) {
17 $new = $xaction->getNewValue();
19 if (empty($map[$new])) {
20 $valid = array_keys($map);
22 $errors[] = $this->newInvalidError(
24 'Authority setting "%s" is not valid. '.
25 'Valid settings are: %s.',
27 implode(', ', $valid)),
35 public function applyInternalEffects($object, $value) {
36 $object->setAuthorityMode($value);
39 public function getTitle() {
40 $map = PhabricatorOwnersPackage
::getAuthorityOptionsMap();
41 $map = ipull($map, 'short');
43 $old = $this->getOldValue();
44 $new = $this->getNewValue();
46 $old = idx($map, $old, $old);
47 $new = idx($map, $new, $new);
50 '%s adjusted package authority rules from %s to %s.',
51 $this->renderAuthor(),
52 $this->renderValue($old),
53 $this->renderValue($new));