1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-02 11:42:42 +01:00
phorge-phorge/src/applications/almanac/editor/AlmanacInterfaceEditor.php
Austin McKinley 4dc8e2de56 Add unique constraint to AlmanacInterfaces
Summary: See discussion in D19379. The 4-tuple of (device, network, address, port) should be unique.

Test Plan: Created lots of duplicate interfaces, bound those interfaces to various services, observed migration script clean things up correctly.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, PHID-OPKG-gm6ozazyms6q6i22gyam

Differential Revision: https://secure.phabricator.com/D19388
2018-04-19 19:16:50 -07:00

36 lines
872 B
PHP

<?php
final class AlmanacInterfaceEditor
extends AlmanacEditor {
public function getEditorObjectsDescription() {
return pht('Almanac Interface');
}
public function getCreateObjectTitle($author, $object) {
return pht('%s created this interface.', $author);
}
public function getCreateObjectTitleForFeed($author, $object) {
return pht('%s created %s.', $author, $object);
}
protected function didCatchDuplicateKeyException(
PhabricatorLiskDAO $object,
array $xactions,
Exception $ex) {
$errors = array();
$errors[] = new PhabricatorApplicationTransactionValidationError(
null,
pht('Invalid'),
pht(
'Interfaces must have a unique combination of network, device, '.
'address, and port.'),
null);
throw new PhabricatorApplicationTransactionValidationException($errors);
}
}