Path: blob/master/src/applications/drydock/controller/DrydockLeaseReleaseController.php
12256 views
<?php12final class DrydockLeaseReleaseController extends DrydockLeaseController {34public function handleRequest(AphrontRequest $request) {5$viewer = $request->getViewer();6$id = $request->getURIData('id');78$lease = id(new DrydockLeaseQuery())9->setViewer($viewer)10->withIDs(array($id))11->requireCapabilities(12array(13PhabricatorPolicyCapability::CAN_VIEW,14PhabricatorPolicyCapability::CAN_EDIT,15))16->executeOne();17if (!$lease) {18return new Aphront404Response();19}2021$lease_uri = '/lease/'.$lease->getID().'/';22$lease_uri = $this->getApplicationURI($lease_uri);2324if (!$lease->canRelease()) {25return $this->newDialog()26->setTitle(pht('Lease Not Releasable'))27->appendParagraph(28pht(29'Leases can not be released after they are destroyed.'))30->addCancelButton($lease_uri);31}3233if ($request->isFormPost()) {34$command = DrydockCommand::initializeNewCommand($viewer)35->setTargetPHID($lease->getPHID())36->setCommand(DrydockCommand::COMMAND_RELEASE)37->save();3839$lease->scheduleUpdate();4041return id(new AphrontRedirectResponse())->setURI($lease_uri);42}4344return $this->newDialog()45->setTitle(pht('Release Lease?'))46->appendParagraph(47pht(48'Forcefully releasing a lease may interfere with the operation '.49'of the lease holder and trigger destruction of the underlying '.50'resource. It can not be undone.'))51->addSubmitButton(pht('Release Lease'))52->addCancelButton($lease_uri);53}5455}565758