forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhragmentSnapshotDeleteController.php
47 lines (37 loc) · 1.29 KB
/
PhragmentSnapshotDeleteController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
final class PhragmentSnapshotDeleteController extends PhragmentController {
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$snapshot = id(new PhragmentSnapshotQuery())
->setViewer($viewer)
->requireCapabilities(array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->withIDs(array($id))
->executeOne();
if ($snapshot === null) {
return new Aphront404Response();
}
if ($request->isDialogFormPost()) {
$fragment_uri = $snapshot->getPrimaryFragment()->getURI();
$snapshot->delete();
return id(new AphrontRedirectResponse())
->setURI($fragment_uri);
}
return $this->createDialog();
}
public function createDialog() {
$viewer = $this->getViewer();
$dialog = id(new AphrontDialogView())
->setTitle(pht('Really delete this snapshot?'))
->setUser($this->getViewer())
->addSubmitButton(pht('Delete'))
->addCancelButton(pht('Cancel'))
->appendParagraph(pht(
'Deleting this snapshot is a permanent operation. You can not '.
'recover the state of the snapshot.'));
return id(new AphrontDialogResponse())->setDialog($dialog);
}
}