Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / almanac / xaction / AlmanacInterfaceNetworkTransaction.php
blobdef85c08e2e912e72d62133c998b0b933834973a
1 <?php
3 final class AlmanacInterfaceNetworkTransaction
4 extends AlmanacInterfaceTransactionType {
6 const TRANSACTIONTYPE = 'almanac:interface:network';
8 public function generateOldValue($object) {
9 return $object->getNetworkPHID();
12 public function applyInternalEffects($object, $value) {
13 $object->setNetworkPHID($value);
16 public function getTitle() {
17 return pht(
18 '%s changed the network for this interface from %s to %s.',
19 $this->renderAuthor(),
20 $this->renderOldHandle(),
21 $this->renderNewHandle());
24 public function validateTransactions($object, array $xactions) {
25 $errors = array();
27 $network_phid = $object->getNetworkPHID();
28 if ($this->isEmptyTextTransaction($network_phid, $xactions)) {
29 $errors[] = $this->newRequiredError(
30 pht('Interfaces must have a network.'));
33 foreach ($xactions as $xaction) {
34 $network_phid = $xaction->getNewValue();
36 $networks = id(new AlmanacNetworkQuery())
37 ->setViewer($this->getActor())
38 ->withPHIDs(array($network_phid))
39 ->execute();
40 if (!$networks) {
41 $errors[] = $this->newInvalidError(
42 pht(
43 'You can not put an interface on a nonexistent or restricted '.
44 'network.'),
45 $xaction);
46 continue;
50 return $errors;