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