1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-17 09:18:44 +01:00
phorge-phorge/src/applications/almanac/controller/AlmanacInterfaceEditController.php
epriestley 6ccf35f9a2 Edit Interfaces in Almanac with EditEngine
Summary:
Depends on D19323. Ref T13120. Ref T12414.

Move editing to modern stuff and fix some implementation errors from D19323 (mostly copy/paste stuff).

Test Plan:
  - Created and edited interfaces.
  - Tried to create/edit an interface with a bogus/empty address/port, got errors.
  - Tried to create an interface on a bogus device, got an error.
  - Tried to create an interface on a device I could not edit, got an error.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13120, T12414

Differential Revision: https://secure.phabricator.com/D19324
2018-04-11 10:29:50 -07:00

35 lines
860 B
PHP

<?php
final class AlmanacInterfaceEditController
extends AlmanacDeviceController {
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$engine = id(new AlmanacInterfaceEditEngine())
->setController($this);
$id = $request->getURIData('id');
if (!$id) {
$device = id(new AlmanacDeviceQuery())
->setViewer($viewer)
->withIDs(array($request->getInt('deviceID')))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$device) {
return new Aphront404Response();
}
$engine
->addContextParameter('deviceID', $device->getID())
->setDevice($device);
}
return $engine->buildResponse();
}
}