Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / owners / xaction / PhabricatorOwnersPackageAutoreviewTransaction.php
blob03ec4f7af11025536f4ccc1d8e91ffe8db9194fa
1 <?php
3 final class PhabricatorOwnersPackageAutoreviewTransaction
4 extends PhabricatorOwnersPackageTransactionType {
6 const TRANSACTIONTYPE = 'owners.autoreview';
8 public function generateOldValue($object) {
9 return $object->getAutoReview();
12 public function validateTransactions($object, array $xactions) {
13 $errors = array();
15 $map = PhabricatorOwnersPackage::getAutoreviewOptionsMap();
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 'Autoreview 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->setAutoReview($value);
39 public function getTitle() {
40 $map = PhabricatorOwnersPackage::getAutoreviewOptionsMap();
41 $map = ipull($map, 'name');
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 autoreview from %s to %s.',
51 $this->renderAuthor(),
52 $this->renderValue($old),
53 $this->renderValue($new));