forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathManiphestTaskSubtaskController.php
71 lines (56 loc) · 1.97 KB
/
ManiphestTaskSubtaskController.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
final class ManiphestTaskSubtaskController
extends ManiphestController {
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$id = $request->getURIData('id');
$task = id(new ManiphestTaskQuery())
->setViewer($viewer)
->withIDs(array($id))
->executeOne();
if (!$task) {
return new Aphront404Response();
}
$cancel_uri = $task->getURI();
$edit_engine = id(new ManiphestEditEngine())
->setViewer($viewer)
->setTargetObject($task);
$subtype_map = $task->newEditEngineSubtypeMap();
$subtype_options = $subtype_map->getCreateFormsForSubtype(
$edit_engine,
$task);
if (!$subtype_options) {
return $this->newDialog()
->setTitle(pht('No Forms'))
->appendParagraph(
pht(
'You do not have access to any forms which can be used to '.
'create a subtask.'))
->addCancelButton($cancel_uri, pht('Close'));
}
$menu = id(new PHUIObjectItemListView())
->setUser($viewer)
->setBig(true)
->setFlush(true);
foreach ($subtype_options as $form_key => $subtype_form) {
$subtype_key = $subtype_form->getSubtype();
$subtype = $subtype_map->getSubtype($subtype_key);
$subtask_uri = id(new PhutilURI("/task/edit/form/{$form_key}/"))
->replaceQueryParam('parent', $id)
->replaceQueryParam('template', $id)
->replaceQueryParam('status', ManiphestTaskStatus::getDefaultStatus());
$subtask_uri = $this->getApplicationURI($subtask_uri);
$item = id(new PHUIObjectItemView())
->setHeader($subtype_form->getDisplayName())
->setHref($subtask_uri)
->setClickable(true)
->setImageIcon($subtype->newIconView())
->addAttribute($subtype->getName());
$menu->addItem($item);
}
return $this->newDialog()
->setTitle(pht('Choose Subtype'))
->appendChild($menu)
->addCancelButton($cancel_uri);
}
}