3 final class DrydockResourceStatus
4 extends PhabricatorObjectStatus
{
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';
12 public static function newStatusObject($key) {
13 return new self($key, id(new self())->getStatusSpecification($key));
16 public static function getStatusMap() {
17 $map = id(new self())->getStatusSpecifications();
18 return ipull($map, 'name', 'key');
21 public static function getNameForStatus($status) {
22 $map = id(new self())->getStatusSpecification($status);
26 public static function getAllStatuses() {
27 return array_keys(id(new self())->getStatusSpecifications());
30 public function isActive() {
31 return ($this->getKey() === self
::STATUS_ACTIVE
);
34 public function canRelease() {
35 return $this->getStatusProperty('isReleasable');
38 public function canReceiveCommands() {
39 return $this->getStatusProperty('isCommandable');
42 protected function newStatusSpecifications() {
45 'key' => self
::STATUS_PENDING
,
46 'name' => pht('Pending'),
47 'icon' => 'fa-clock-o',
49 'isReleasable' => true,
50 'isCommandable' => true,
53 'key' => self
::STATUS_ACTIVE
,
54 'name' => pht('Active'),
57 'isReleasable' => true,
58 'isCommandable' => true,
61 'key' => self
::STATUS_RELEASED
,
62 'name' => pht('Released'),
63 'icon' => 'fa-circle-o',
65 'isReleasable' => false,
66 'isCommandable' => false,
69 'key' => self
::STATUS_BROKEN
,
70 'name' => pht('Broken'),
73 'isReleasable' => true,
74 'isCommandable' => false,
77 'key' => self
::STATUS_DESTROYED
,
78 'name' => pht('Destroyed'),
81 'isReleasable' => false,
82 'isCommandable' => false,
87 protected function newUnknownStatusSpecification($status) {
89 'isReleasable' => false,
90 'isCommandable' => false,