Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / almanac / xaction / AlmanacInterfacePortTransaction.php
blob5e8e11b805b67156fead8545208b6280f8965078
1 <?php
3 final class AlmanacInterfacePortTransaction
4 extends AlmanacInterfaceTransactionType {
6 const TRANSACTIONTYPE = 'almanac:interface:port';
8 public function generateOldValue($object) {
9 $port = $object->getPort();
11 if ($port !== null) {
12 $port = (int)$port;
15 return $port;
18 public function applyInternalEffects($object, $value) {
19 $object->setPort((int)$value);
22 public function getTitle() {
23 return pht(
24 '%s changed the port for this interface from %s to %s.',
25 $this->renderAuthor(),
26 $this->renderOldValue(),
27 $this->renderNewValue());
30 public function validateTransactions($object, array $xactions) {
31 $errors = array();
33 if ($this->isEmptyTextTransaction($object->getPort(), $xactions)) {
34 $errors[] = $this->newRequiredError(
35 pht('Interfaces must have a port number.'));
38 foreach ($xactions as $xaction) {
39 $port = $xaction->getNewValue();
41 $port = (int)$port;
42 if ($port < 1 || $port > 65535) {
43 $errors[] = $this->newInvalidError(
44 pht('Port numbers must be between 1 and 65535, inclusive.'),
45 $xaction);
46 continue;
50 return $errors;