Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / owners / xaction / PhabricatorOwnersPackageAuthorityTransaction.php
blobf01a6bf5fe05562fa9615b10d8652b93e87dcecc
1 <?php
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) {
13 $errors = array();
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(
23 pht(
24 'Authority setting "%s" is not valid. '.
25 'Valid settings are: %s.',
26 $new,
27 implode(', ', $valid)),
28 $xaction);
32 return $errors;
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);
49 return pht(
50 '%s adjusted package authority rules from %s to %s.',
51 $this->renderAuthor(),
52 $this->renderValue($old),
53 $this->renderValue($new));