Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/drydock/controller/DrydockLeaseReleaseController.php
12256 views
1
<?php
2
3
final class DrydockLeaseReleaseController extends DrydockLeaseController {
4
5
public function handleRequest(AphrontRequest $request) {
6
$viewer = $request->getViewer();
7
$id = $request->getURIData('id');
8
9
$lease = id(new DrydockLeaseQuery())
10
->setViewer($viewer)
11
->withIDs(array($id))
12
->requireCapabilities(
13
array(
14
PhabricatorPolicyCapability::CAN_VIEW,
15
PhabricatorPolicyCapability::CAN_EDIT,
16
))
17
->executeOne();
18
if (!$lease) {
19
return new Aphront404Response();
20
}
21
22
$lease_uri = '/lease/'.$lease->getID().'/';
23
$lease_uri = $this->getApplicationURI($lease_uri);
24
25
if (!$lease->canRelease()) {
26
return $this->newDialog()
27
->setTitle(pht('Lease Not Releasable'))
28
->appendParagraph(
29
pht(
30
'Leases can not be released after they are destroyed.'))
31
->addCancelButton($lease_uri);
32
}
33
34
if ($request->isFormPost()) {
35
$command = DrydockCommand::initializeNewCommand($viewer)
36
->setTargetPHID($lease->getPHID())
37
->setCommand(DrydockCommand::COMMAND_RELEASE)
38
->save();
39
40
$lease->scheduleUpdate();
41
42
return id(new AphrontRedirectResponse())->setURI($lease_uri);
43
}
44
45
return $this->newDialog()
46
->setTitle(pht('Release Lease?'))
47
->appendParagraph(
48
pht(
49
'Forcefully releasing a lease may interfere with the operation '.
50
'of the lease holder and trigger destruction of the underlying '.
51
'resource. It can not be undone.'))
52
->addSubmitButton(pht('Release Lease'))
53
->addCancelButton($lease_uri);
54
}
55
56
}
57
58