Path: blob/master/src/applications/almanac/controller/AlmanacInterfaceDeleteController.php
12256 views
<?php12final class AlmanacInterfaceDeleteController3extends AlmanacDeviceController {45public function handleRequest(AphrontRequest $request) {6$viewer = $request->getViewer();78$id = $request->getURIData('id');9$interface = id(new AlmanacInterfaceQuery())10->setViewer($viewer)11->withIDs(array($id))12->requireCapabilities(13array(14PhabricatorPolicyCapability::CAN_VIEW,15PhabricatorPolicyCapability::CAN_EDIT,16))17->executeOne();18if (!$interface) {19return new Aphront404Response();20}2122$device = $interface->getDevice();23$device_uri = $device->getURI();2425if ($interface->loadIsInUse()) {26return $this->newDialog()27->setTitle(pht('Interface In Use'))28->appendParagraph(29pht(30'You can not delete this interface because it is currently in '.31'use. One or more services are bound to it.'))32->addCancelButton($device_uri);33}3435if ($request->isFormPost()) {36$type_destroy = AlmanacInterfaceDestroyTransaction::TRANSACTIONTYPE;3738$xactions = array();3940$xactions[] = $interface->getApplicationTransactionTemplate()41->setTransactionType($type_destroy)42->setNewValue(true);4344$editor = id(new AlmanacInterfaceEditor())45->setActor($viewer)46->setContentSourceFromRequest($request)47->setContinueOnNoEffect(true)48->setContinueOnMissingFields(true);4950$editor->applyTransactions($interface, $xactions);5152return id(new AphrontRedirectResponse())->setURI($device_uri);53}5455return $this->newDialog()56->setTitle(pht('Delete Interface'))57->appendParagraph(58pht(59'Remove interface %s on device %s?',60phutil_tag('strong', array(), $interface->renderDisplayAddress()),61phutil_tag('strong', array(), $device->getName())))62->addCancelButton($device_uri)63->addSubmitButton(pht('Delete Interface'));64}6566}676869