Path: blob/master/src/applications/harbormaster/constants/HarbormasterBuildableStatus.php
12256 views
<?php12final class HarbormasterBuildableStatus extends Phobject {34const STATUS_PREPARING = 'preparing';5const STATUS_BUILDING = 'building';6const STATUS_PASSED = 'passed';7const STATUS_FAILED = 'failed';89private $key;10private $properties;1112public function __construct($key, array $properties) {13$this->key = $key;14$this->properties = $properties;15}1617public static function newBuildableStatusObject($status) {18$spec = self::getSpecification($status);19return new self($status, $spec);20}2122private function getProperty($key) {23if (!array_key_exists($key, $this->properties)) {24throw new Exception(25pht(26'Attempting to access unknown buildable status property ("%s").',27$key));28}2930return $this->properties[$key];31}3233public function getIcon() {34return $this->getProperty('icon');35}3637public function getDisplayName() {38return $this->getProperty('name');39}4041public function getActionName() {42return $this->getProperty('name.action');43}4445public function getColor() {46return $this->getProperty('color');47}4849public function isPreparing() {50return ($this->key === self::STATUS_PREPARING);51}5253public function isBuilding() {54return ($this->key === self::STATUS_BUILDING);55}5657public function isFailed() {58return ($this->key === self::STATUS_FAILED);59}6061public static function getOptionMap() {62return ipull(self::getSpecifications(), 'name');63}6465private static function getSpecifications() {66return array(67self::STATUS_PREPARING => array(68'name' => pht('Preparing'),69'color' => 'blue',70'icon' => 'fa-hourglass-o',71'name.action' => pht('Build Preparing'),72),73self::STATUS_BUILDING => array(74'name' => pht('Building'),75'color' => 'blue',76'icon' => 'fa-chevron-circle-right',77'name.action' => pht('Build Started'),78),79self::STATUS_PASSED => array(80'name' => pht('Passed'),81'color' => 'green',82'icon' => 'fa-check-circle',83'name.action' => pht('Build Passed'),84),85self::STATUS_FAILED => array(86'name' => pht('Failed'),87'color' => 'red',88'icon' => 'fa-times-circle',89'name.action' => pht('Build Failed'),90),91);92}9394private static function getSpecification($status) {95$map = self::getSpecifications();96if (isset($map[$status])) {97return $map[$status];98}99100return array(101'name' => pht('Unknown ("%s")', $status),102'icon' => 'fa-question-circle',103'color' => 'bluegrey',104'name.action' => pht('Build Status'),105);106}107108}109110111