Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / drydock / constants / DrydockResourceStatus.php
blob197a220630f902160eb0898266866fb7a69168c4
1 <?php
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);
23 return $map['name'];
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() {
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,
52 array(
53 'key' => self::STATUS_ACTIVE,
54 'name' => pht('Active'),
55 'icon' => 'fa-check',
56 'color' => 'green',
57 'isReleasable' => true,
58 'isCommandable' => true,
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,
68 array(
69 'key' => self::STATUS_BROKEN,
70 'name' => pht('Broken'),
71 'icon' => 'fa-times',
72 'color' => 'indigo',
73 'isReleasable' => true,
74 'isCommandable' => false,
76 array(
77 'key' => self::STATUS_DESTROYED,
78 'name' => pht('Destroyed'),
79 'icon' => 'fa-times',
80 'color' => 'grey',
81 'isReleasable' => false,
82 'isCommandable' => false,
87 protected function newUnknownStatusSpecification($status) {
88 return array(
89 'isReleasable' => false,
90 'isCommandable' => false,