Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/drydock/controller/DrydockLogController.php
12262 views
1
<?php
2
3
abstract class DrydockLogController
4
extends DrydockController {
5
6
private $blueprint;
7
private $resource;
8
private $lease;
9
private $operation;
10
11
public function setBlueprint(DrydockBlueprint $blueprint) {
12
$this->blueprint = $blueprint;
13
return $this;
14
}
15
16
public function getBlueprint() {
17
return $this->blueprint;
18
}
19
20
public function setResource(DrydockResource $resource) {
21
$this->resource = $resource;
22
return $this;
23
}
24
25
public function getResource() {
26
return $this->resource;
27
}
28
29
public function setLease(DrydockLease $lease) {
30
$this->lease = $lease;
31
return $this;
32
}
33
34
public function getLease() {
35
return $this->lease;
36
}
37
38
public function setOperation(DrydockRepositoryOperation $operation) {
39
$this->operation = $operation;
40
return $this;
41
}
42
43
public function getOperation() {
44
return $this->operation;
45
}
46
47
public function buildSideNavView() {
48
$nav = new AphrontSideNavFilterView();
49
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
50
51
$engine = id(new DrydockLogSearchEngine())
52
->setViewer($this->getRequest()->getUser());
53
54
$blueprint = $this->getBlueprint();
55
if ($blueprint) {
56
$engine->setBlueprint($blueprint);
57
}
58
59
$resource = $this->getResource();
60
if ($resource) {
61
$engine->setResource($resource);
62
}
63
64
$lease = $this->getLease();
65
if ($lease) {
66
$engine->setLease($lease);
67
}
68
69
$operation = $this->getOperation();
70
if ($operation) {
71
$engine->setOperation($operation);
72
}
73
74
$engine->addNavigationItems($nav->getMenu());
75
76
$nav->selectFilter(null);
77
78
return $nav;
79
}
80
81
protected function buildApplicationCrumbs() {
82
$crumbs = parent::buildApplicationCrumbs();
83
84
$viewer = $this->getViewer();
85
86
$blueprint = $this->getBlueprint();
87
$resource = $this->getResource();
88
$lease = $this->getLease();
89
$operation = $this->getOperation();
90
if ($blueprint) {
91
$id = $blueprint->getID();
92
93
$crumbs->addTextCrumb(
94
pht('Blueprints'),
95
$this->getApplicationURI('blueprint/'));
96
97
$crumbs->addTextCrumb(
98
$blueprint->getBlueprintName(),
99
$this->getApplicationURI("blueprint/{$id}/"));
100
101
$crumbs->addTextCrumb(
102
pht('Logs'),
103
$this->getApplicationURI("blueprint/{$id}/logs/"));
104
} else if ($resource) {
105
$id = $resource->getID();
106
107
$crumbs->addTextCrumb(
108
pht('Resources'),
109
$this->getApplicationURI('resource/'));
110
111
$crumbs->addTextCrumb(
112
$resource->getResourceName(),
113
$this->getApplicationURI("resource/{$id}/"));
114
115
$crumbs->addTextCrumb(
116
pht('Logs'),
117
$this->getApplicationURI("resource/{$id}/logs/"));
118
} else if ($lease) {
119
$id = $lease->getID();
120
121
$crumbs->addTextCrumb(
122
pht('Leases'),
123
$this->getApplicationURI('lease/'));
124
125
$crumbs->addTextCrumb(
126
$lease->getLeaseName(),
127
$this->getApplicationURI("lease/{$id}/"));
128
129
$crumbs->addTextCrumb(
130
pht('Logs'),
131
$this->getApplicationURI("lease/{$id}/logs/"));
132
} else if ($operation) {
133
$id = $operation->getID();
134
135
$crumbs->addTextCrumb(
136
pht('Operations'),
137
$this->getApplicationURI('operation/'));
138
139
$crumbs->addTextCrumb(
140
pht('Repository Operation %d', $id),
141
$this->getApplicationURI("operation/{$id}/"));
142
143
$crumbs->addTextCrumb(
144
pht('Logs'),
145
$this->getApplicationURI("operation/{$id}/logs/"));
146
}
147
148
return $crumbs;
149
}
150
151
}
152
153