Remove product literal strings in "pht()", part 18
[phabricator.git] / src / applications / harbormaster / constants / HarbormasterBuildableStatus.php
blobd7e88ed2972a741818a480f0ba7a05ff3f20603d
1 <?php
3 final class HarbormasterBuildableStatus extends Phobject {
5 const STATUS_PREPARING = 'preparing';
6 const STATUS_BUILDING = 'building';
7 const STATUS_PASSED = 'passed';
8 const STATUS_FAILED = 'failed';
10 private $key;
11 private $properties;
13 public function __construct($key, array $properties) {
14 $this->key = $key;
15 $this->properties = $properties;
18 public static function newBuildableStatusObject($status) {
19 $spec = self::getSpecification($status);
20 return new self($status, $spec);
23 private function getProperty($key) {
24 if (!array_key_exists($key, $this->properties)) {
25 throw new Exception(
26 pht(
27 'Attempting to access unknown buildable status property ("%s").',
28 $key));
31 return $this->properties[$key];
34 public function getIcon() {
35 return $this->getProperty('icon');
38 public function getDisplayName() {
39 return $this->getProperty('name');
42 public function getActionName() {
43 return $this->getProperty('name.action');
46 public function getColor() {
47 return $this->getProperty('color');
50 public function isPreparing() {
51 return ($this->key === self::STATUS_PREPARING);
54 public function isBuilding() {
55 return ($this->key === self::STATUS_BUILDING);
58 public function isFailed() {
59 return ($this->key === self::STATUS_FAILED);
62 public static function getOptionMap() {
63 return ipull(self::getSpecifications(), 'name');
66 private static function getSpecifications() {
67 return array(
68 self::STATUS_PREPARING => array(
69 'name' => pht('Preparing'),
70 'color' => 'blue',
71 'icon' => 'fa-hourglass-o',
72 'name.action' => pht('Build Preparing'),
74 self::STATUS_BUILDING => array(
75 'name' => pht('Building'),
76 'color' => 'blue',
77 'icon' => 'fa-chevron-circle-right',
78 'name.action' => pht('Build Started'),
80 self::STATUS_PASSED => array(
81 'name' => pht('Passed'),
82 'color' => 'green',
83 'icon' => 'fa-check-circle',
84 'name.action' => pht('Build Passed'),
86 self::STATUS_FAILED => array(
87 'name' => pht('Failed'),
88 'color' => 'red',
89 'icon' => 'fa-times-circle',
90 'name.action' => pht('Build Failed'),
95 private static function getSpecification($status) {
96 $map = self::getSpecifications();
97 if (isset($map[$status])) {
98 return $map[$status];
101 return array(
102 'name' => pht('Unknown ("%s")', $status),
103 'icon' => 'fa-question-circle',
104 'color' => 'bluegrey',
105 'name.action' => pht('Build Status'),