Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/drydock/storage/DrydockLog.php
12256 views
1
<?php
2
3
final class DrydockLog extends DrydockDAO
4
implements PhabricatorPolicyInterface {
5
6
protected $blueprintPHID;
7
protected $resourcePHID;
8
protected $leasePHID;
9
protected $operationPHID;
10
protected $epoch;
11
protected $type;
12
protected $data = array();
13
14
private $blueprint = self::ATTACHABLE;
15
private $resource = self::ATTACHABLE;
16
private $lease = self::ATTACHABLE;
17
private $operation = self::ATTACHABLE;
18
19
protected function getConfiguration() {
20
return array(
21
self::CONFIG_TIMESTAMPS => false,
22
self::CONFIG_SERIALIZATION => array(
23
'data' => self::SERIALIZATION_JSON,
24
),
25
self::CONFIG_COLUMN_SCHEMA => array(
26
'blueprintPHID' => 'phid?',
27
'resourcePHID' => 'phid?',
28
'leasePHID' => 'phid?',
29
'operationPHID' => 'phid?',
30
'type' => 'text64',
31
),
32
self::CONFIG_KEY_SCHEMA => array(
33
'key_blueprint' => array(
34
'columns' => array('blueprintPHID', 'type'),
35
),
36
'key_resource' => array(
37
'columns' => array('resourcePHID', 'type'),
38
),
39
'key_lease' => array(
40
'columns' => array('leasePHID', 'type'),
41
),
42
'key_operation' => array(
43
'columns' => array('operationPHID', 'type'),
44
),
45
'epoch' => array(
46
'columns' => array('epoch'),
47
),
48
),
49
) + parent::getConfiguration();
50
}
51
52
public function attachBlueprint(DrydockBlueprint $blueprint = null) {
53
$this->blueprint = $blueprint;
54
return $this;
55
}
56
57
public function getBlueprint() {
58
return $this->assertAttached($this->blueprint);
59
}
60
61
public function attachResource(DrydockResource $resource = null) {
62
$this->resource = $resource;
63
return $this;
64
}
65
66
public function getResource() {
67
return $this->assertAttached($this->resource);
68
}
69
70
public function attachLease(DrydockLease $lease = null) {
71
$this->lease = $lease;
72
return $this;
73
}
74
75
public function getLease() {
76
return $this->assertAttached($this->lease);
77
}
78
79
public function attachOperation(
80
DrydockRepositoryOperation $operation = null) {
81
$this->operation = $operation;
82
return $this;
83
}
84
85
public function getOperation() {
86
return $this->assertAttached($this->operation);
87
}
88
89
public function isComplete() {
90
if ($this->getBlueprintPHID() && !$this->getBlueprint()) {
91
return false;
92
}
93
94
if ($this->getResourcePHID() && !$this->getResource()) {
95
return false;
96
}
97
98
if ($this->getLeasePHID() && !$this->getLease()) {
99
return false;
100
}
101
102
if ($this->getOperationPHID() && !$this->getOperation()) {
103
return false;
104
}
105
106
return true;
107
}
108
109
110
/* -( PhabricatorPolicyInterface )----------------------------------------- */
111
112
113
public function getCapabilities() {
114
return array(
115
PhabricatorPolicyCapability::CAN_VIEW,
116
);
117
}
118
119
public function getPolicy($capability) {
120
// NOTE: We let you see that logs exist no matter what, but don't actually
121
// show you log content unless you can see all of the associated objects.
122
return PhabricatorPolicies::getMostOpenPolicy();
123
}
124
125
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
126
return false;
127
}
128
129
public function describeAutomaticCapability($capability) {
130
return pht(
131
'To view log details, you must be able to view all associated '.
132
'blueprints, resources, leases, and repository operations.');
133
}
134
135
}
136
137