Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/drydock/constants/DrydockLeaseStatus.php
12256 views
1
<?php
2
3
final class DrydockLeaseStatus
4
extends PhabricatorObjectStatus {
5
6
const STATUS_PENDING = 'pending';
7
const STATUS_ACQUIRED = 'acquired';
8
const STATUS_ACTIVE = 'active';
9
const STATUS_RELEASED = 'released';
10
const STATUS_BROKEN = 'broken';
11
const STATUS_DESTROYED = 'destroyed';
12
13
public static function newStatusObject($key) {
14
return new self($key, id(new self())->getStatusSpecification($key));
15
}
16
17
public static function getStatusMap() {
18
$map = id(new self())->getStatusSpecifications();
19
return ipull($map, 'name', 'key');
20
}
21
22
public static function getNameForStatus($status) {
23
$map = id(new self())->getStatusSpecification($status);
24
return $map['name'];
25
}
26
27
public static function getAllStatuses() {
28
return array_keys(id(new self())->getStatusSpecifications());
29
}
30
31
public function isActivating() {
32
return $this->getStatusProperty('isActivating');
33
}
34
35
public function isActive() {
36
return ($this->getKey() === self::STATUS_ACTIVE);
37
}
38
39
public function canRelease() {
40
return $this->getStatusProperty('isReleasable');
41
}
42
43
public function canReceiveCommands() {
44
return $this->getStatusProperty('isCommandable');
45
}
46
47
protected function newStatusSpecifications() {
48
return array(
49
array(
50
'key' => self::STATUS_PENDING,
51
'name' => pht('Pending'),
52
'icon' => 'fa-clock-o',
53
'color' => 'blue',
54
'isReleasable' => true,
55
'isCommandable' => true,
56
'isActivating' => true,
57
),
58
array(
59
'key' => self::STATUS_ACQUIRED,
60
'name' => pht('Acquired'),
61
'icon' => 'fa-refresh',
62
'color' => 'blue',
63
'isReleasable' => true,
64
'isCommandable' => true,
65
'isActivating' => true,
66
),
67
array(
68
'key' => self::STATUS_ACTIVE,
69
'name' => pht('Active'),
70
'icon' => 'fa-check',
71
'color' => 'green',
72
'isReleasable' => true,
73
'isCommandable' => true,
74
'isActivating' => false,
75
),
76
array(
77
'key' => self::STATUS_RELEASED,
78
'name' => pht('Released'),
79
'icon' => 'fa-circle-o',
80
'color' => 'blue',
81
'isReleasable' => false,
82
'isCommandable' => false,
83
'isActivating' => false,
84
),
85
array(
86
'key' => self::STATUS_BROKEN,
87
'name' => pht('Broken'),
88
'icon' => 'fa-times',
89
'color' => 'indigo',
90
'isReleasable' => true,
91
'isCommandable' => true,
92
'isActivating' => false,
93
),
94
array(
95
'key' => self::STATUS_DESTROYED,
96
'name' => pht('Destroyed'),
97
'icon' => 'fa-times',
98
'color' => 'grey',
99
'isReleasable' => false,
100
'isCommandable' => false,
101
'isActivating' => false,
102
),
103
);
104
}
105
106
protected function newUnknownStatusSpecification($status) {
107
return array(
108
'isReleasable' => false,
109
'isCommandable' => false,
110
'isActivating' => false,
111
);
112
}
113
114
}
115
116