Path: blob/master/src/applications/almanac/xaction/AlmanacInterfacePortTransaction.php
12256 views
<?php12final class AlmanacInterfacePortTransaction3extends AlmanacInterfaceTransactionType {45const TRANSACTIONTYPE = 'almanac:interface:port';67public function generateOldValue($object) {8$port = $object->getPort();910if ($port !== null) {11$port = (int)$port;12}1314return $port;15}1617public function applyInternalEffects($object, $value) {18$object->setPort((int)$value);19}2021public function getTitle() {22return pht(23'%s changed the port for this interface from %s to %s.',24$this->renderAuthor(),25$this->renderOldValue(),26$this->renderNewValue());27}2829public function validateTransactions($object, array $xactions) {30$errors = array();3132if ($this->isEmptyTextTransaction($object->getPort(), $xactions)) {33$errors[] = $this->newRequiredError(34pht('Interfaces must have a port number.'));35}3637foreach ($xactions as $xaction) {38$port = $xaction->getNewValue();3940$port = (int)$port;41if ($port < 1 || $port > 65535) {42$errors[] = $this->newInvalidError(43pht('Port numbers must be between 1 and 65535, inclusive.'),44$xaction);45continue;46}47}4849return $errors;50}5152}535455