forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathDifferentialRevisionEditController.php
56 lines (46 loc) · 1.48 KB
/
DifferentialRevisionEditController.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
48
49
50
51
52
53
54
55
56
<?php
final class DifferentialRevisionEditController
extends DifferentialController {
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
// If we have a Diff ID, this is an "/attach/123/to/456/" action. The
// user just created a diff and is trying to use it to create or update
// a revision.
$diff_id = $request->getURIData('diffID');
if ($diff_id) {
$diff = id(new DifferentialDiffQuery())
->setViewer($viewer)
->withIDs(array($diff_id))
->executeOne();
if (!$diff) {
return new Aphront404Response();
}
if ($diff->getRevisionID()) {
$revision = $diff->getRevision();
return $this->newDialog()
->setTitle(pht('Diff Already Attached'))
->appendParagraph(
pht(
'This diff is already attached to a revision.'))
->addCancelButton($revision->getURI(), pht('Continue'));
}
} else {
$diff = null;
}
$revision_id = $request->getURIData('id');
if (!$diff && !$revision_id) {
return $this->newDialog()
->setTitle(pht('Diff Required'))
->appendParagraph(
pht(
'You can not create a revision without a diff.'))
->addCancelButton($this->getApplicationURI());
}
$engine = id(new DifferentialRevisionEditEngine())
->setController($this);
if ($diff) {
$engine->setDiff($diff);
}
return $engine->buildResponse();
}
}