3 final class AlmanacInterfaceDeleteController
4 extends AlmanacDeviceController
{
6 public function handleRequest(AphrontRequest
$request) {
7 $viewer = $request->getViewer();
9 $id = $request->getURIData('id');
10 $interface = id(new AlmanacInterfaceQuery())
13 ->requireCapabilities(
15 PhabricatorPolicyCapability
::CAN_VIEW
,
16 PhabricatorPolicyCapability
::CAN_EDIT
,
20 return new Aphront404Response();
23 $device = $interface->getDevice();
24 $device_uri = $device->getURI();
26 if ($interface->loadIsInUse()) {
27 return $this->newDialog()
28 ->setTitle(pht('Interface In Use'))
31 'You can not delete this interface because it is currently in '.
32 'use. One or more services are bound to it.'))
33 ->addCancelButton($device_uri);
36 if ($request->isFormPost()) {
37 $type_destroy = AlmanacInterfaceDestroyTransaction
::TRANSACTIONTYPE
;
41 $xactions[] = $interface->getApplicationTransactionTemplate()
42 ->setTransactionType($type_destroy)
45 $editor = id(new AlmanacInterfaceEditor())
47 ->setContentSourceFromRequest($request)
48 ->setContinueOnNoEffect(true)
49 ->setContinueOnMissingFields(true);
51 $editor->applyTransactions($interface, $xactions);
53 return id(new AphrontRedirectResponse())->setURI($device_uri);
56 return $this->newDialog()
57 ->setTitle(pht('Delete Interface'))
60 'Remove interface %s on device %s?',
61 phutil_tag('strong', array(), $interface->renderDisplayAddress()),
62 phutil_tag('strong', array(), $device->getName())))
63 ->addCancelButton($device_uri)
64 ->addSubmitButton(pht('Delete Interface'));