3 final class AlmanacInterfaceDeviceTransaction
4 extends AlmanacInterfaceTransactionType
{
6 const TRANSACTIONTYPE
= 'almanac:interface:device';
8 public function generateOldValue($object) {
9 return $object->getDevicePHID();
12 public function applyInternalEffects($object, $value) {
13 $object->setDevicePHID($value);
16 public function getTitle() {
18 '%s changed the device for this interface from %s to %s.',
19 $this->renderAuthor(),
20 $this->renderOldHandle(),
21 $this->renderNewHandle());
24 public function validateTransactions($object, array $xactions) {
27 $device_phid = $object->getDevicePHID();
28 if ($this->isEmptyTextTransaction($device_phid, $xactions)) {
29 $errors[] = $this->newRequiredError(
30 pht('Interfaces must have a device.'));
33 foreach ($xactions as $xaction) {
34 if (!$this->isNewObject()) {
35 $errors[] = $this->newInvalidError(
37 'The device for an interface can not be changed once it has '.
43 $device_phid = $xaction->getNewValue();
44 $devices = id(new AlmanacDeviceQuery())
45 ->setViewer($this->getActor())
46 ->withPHIDs(array($device_phid))
49 $errors[] = $this->newInvalidError(
51 'You can not attach an interface to a nonexistent or restricted '.
57 $device = head($devices);
58 $can_edit = PhabricatorPolicyFilter
::hasCapability(
61 PhabricatorPolicyCapability
::CAN_EDIT
);
63 $errors[] = $this->newInvalidError(
65 'You can not attach an interface to a device which you do not '.
66 'have permission to edit.'));