Path: blob/master/src/applications/almanac/xaction/AlmanacInterfaceNetworkTransaction.php
12256 views
<?php12final class AlmanacInterfaceNetworkTransaction3extends AlmanacInterfaceTransactionType {45const TRANSACTIONTYPE = 'almanac:interface:network';67public function generateOldValue($object) {8return $object->getNetworkPHID();9}1011public function applyInternalEffects($object, $value) {12$object->setNetworkPHID($value);13}1415public function getTitle() {16return pht(17'%s changed the network for this interface from %s to %s.',18$this->renderAuthor(),19$this->renderOldHandle(),20$this->renderNewHandle());21}2223public function validateTransactions($object, array $xactions) {24$errors = array();2526$network_phid = $object->getNetworkPHID();27if ($this->isEmptyTextTransaction($network_phid, $xactions)) {28$errors[] = $this->newRequiredError(29pht('Interfaces must have a network.'));30}3132foreach ($xactions as $xaction) {33$network_phid = $xaction->getNewValue();3435$networks = id(new AlmanacNetworkQuery())36->setViewer($this->getActor())37->withPHIDs(array($network_phid))38->execute();39if (!$networks) {40$errors[] = $this->newInvalidError(41pht(42'You can not put an interface on a nonexistent or restricted '.43'network.'),44$xaction);45continue;46}47}4849return $errors;50}5152}535455