Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/almanac/xaction/AlmanacInterfaceAddressTransaction.php
12256 views
1
<?php
2
3
final class AlmanacInterfaceAddressTransaction
4
extends AlmanacInterfaceTransactionType {
5
6
const TRANSACTIONTYPE = 'almanac:interface:address';
7
8
public function generateOldValue($object) {
9
return $object->getAddress();
10
}
11
12
public function applyInternalEffects($object, $value) {
13
$object->setAddress($value);
14
}
15
16
public function getTitle() {
17
return pht(
18
'%s changed the address for this interface from %s to %s.',
19
$this->renderAuthor(),
20
$this->renderOldValue(),
21
$this->renderNewValue());
22
}
23
24
public function validateTransactions($object, array $xactions) {
25
$errors = array();
26
27
if ($this->isEmptyTextTransaction($object->getAddress(), $xactions)) {
28
$errors[] = $this->newRequiredError(
29
pht('Interfaces must have an address.'));
30
}
31
32
foreach ($xactions as $xaction) {
33
34
// NOTE: For now, we don't validate addresses. We generally expect users
35
// to provide IPv4 addresses, but it's reasonable for them to provide
36
// IPv6 addresses, and some installs currently use DNS names. This is
37
// off-label but works today.
38
39
}
40
41
return $errors;
42
}
43
44
}
45
46