Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/dashboard/install/PhabricatorDashboardInstallWorkflow.php
12242 views
1
<?php
2
3
abstract class PhabricatorDashboardInstallWorkflow
4
extends Phobject {
5
6
private $request;
7
private $viewer;
8
private $dashboard;
9
private $mode;
10
11
final public function setViewer(PhabricatorUser $viewer) {
12
$this->viewer = $viewer;
13
return $this;
14
}
15
16
final public function getViewer() {
17
return $this->viewer;
18
}
19
20
final public function setDashboard(PhabricatorDashboard $dashboard) {
21
$this->dashboard = $dashboard;
22
return $this;
23
}
24
25
final public function getDashboard() {
26
return $this->dashboard;
27
}
28
29
final public function setMode($mode) {
30
$this->mode = $mode;
31
return $this;
32
}
33
34
final public function getMode() {
35
return $this->mode;
36
}
37
38
final public function setRequest(AphrontRequest $request) {
39
$this->request = $request;
40
return $this;
41
}
42
43
final public function getRequest() {
44
return $this->request;
45
}
46
47
final public function getWorkflowKey() {
48
return $this->getPhobjectClassConstant('WORKFLOWKEY', 32);
49
}
50
51
final public static function getAllWorkflows() {
52
return id(new PhutilClassMapQuery())
53
->setAncestorClass(__CLASS__)
54
->setUniqueMethod('getWorkflowKey')
55
->setSortMethod('getOrder')
56
->execute();
57
}
58
59
final public function getWorkflowMenuItem() {
60
return $this->newWorkflowMenuItem();
61
}
62
63
abstract public function getOrder();
64
abstract protected function newWorkflowMenuItem();
65
66
final protected function newMenuItem() {
67
return id(new PHUIObjectItemView())
68
->setClickable(true);
69
}
70
71
abstract public function handleRequest(AphrontRequest $request);
72
73
final protected function newDialog() {
74
$dashboard = $this->getDashboard();
75
76
return id(new AphrontDialogView())
77
->setViewer($this->getViewer())
78
->setWidth(AphrontDialogView::WIDTH_FORM)
79
->addCancelButton($dashboard->getURI());
80
}
81
82
final protected function newMenuFromItemMap(array $map) {
83
$viewer = $this->getViewer();
84
$dashboard = $this->getDashboard();
85
86
$menu = id(new PHUIObjectItemListView())
87
->setViewer($viewer)
88
->setFlush(true)
89
->setBig(true);
90
91
foreach ($map as $key => $item) {
92
$item->setHref(
93
urisprintf(
94
'/dashboard/install/%d/%s/%s/',
95
$dashboard->getID(),
96
$this->getWorkflowKey(),
97
$key));
98
99
$menu->addItem($item);
100
}
101
102
return $menu;
103
}
104
105
abstract protected function newProfileEngine();
106
107
final protected function installDashboard($profile_object, $custom_phid) {
108
$dashboard = $this->getDashboard();
109
$engine = $this->newProfileEngine()
110
->setProfileObject($profile_object);
111
112
$request = $this->getRequest();
113
$viewer = $this->getViewer();
114
115
$config = PhabricatorProfileMenuItemConfiguration::initializeNewItem(
116
$profile_object,
117
new PhabricatorDashboardProfileMenuItem(),
118
$custom_phid);
119
120
$config->setMenuItemProperty('dashboardPHID', $dashboard->getPHID());
121
122
$xactions = array();
123
124
$editor = id(new PhabricatorProfileMenuEditor())
125
->setActor($viewer)
126
->setContinueOnNoEffect(true)
127
->setContinueOnMissingFields(true)
128
->setContentSourceFromRequest($request);
129
130
$editor->applyTransactions($config, $xactions);
131
132
$done_uri = $engine->getItemURI(urisprintf('view/%d/', $config->getID()));
133
134
return id(new AphrontRedirectResponse())
135
->setURI($done_uri);
136
}
137
138
final protected function getDashboardDisplayName() {
139
$dashboard = $this->getDashboard();
140
return phutil_tag('strong', array(), $dashboard->getName());
141
}
142
143
}
144
145