Path: blob/master/src/infrastructure/status/PhabricatorObjectStatus.php
12249 views
<?php12abstract class PhabricatorObjectStatus3extends Phobject {45private $key;6private $properties;78protected function __construct($key = null, array $properties = array()) {9$this->key = $key;10$this->properties = $properties;11}1213protected function getStatusProperty($key) {14if (!array_key_exists($key, $this->properties)) {15throw new Exception(16pht(17'Attempting to access unknown status property ("%s").',18$key));19}2021return $this->properties[$key];22}2324public function getKey() {25return $this->key;26}2728public function getIcon() {29return $this->getStatusProperty('icon');30}3132public function getDisplayName() {33return $this->getStatusProperty('name');34}3536public function getColor() {37return $this->getStatusProperty('color');38}3940protected function getStatusSpecification($status) {41$map = self::getStatusSpecifications();42if (isset($map[$status])) {43return $map[$status];44}4546return array(47'key' => $status,48'name' => pht('Unknown ("%s")', $status),49'icon' => 'fa-question-circle',50'color' => 'indigo',51) + $this->newUnknownStatusSpecification($status);52}5354protected function getStatusSpecifications() {55$map = $this->newStatusSpecifications();5657$result = array();58foreach ($map as $item) {59if (!array_key_exists('key', $item)) {60throw new Exception(pht('Status specification has no "key".'));61}6263$key = $item['key'];64if (isset($result[$key])) {65throw new Exception(66pht(67'Multiple status definitions share the same key ("%s").',68$key));69}7071$result[$key] = $item;72}7374return $result;75}7677abstract protected function newStatusSpecifications();7879protected function newUnknownStatusSpecification($status) {80return array();81}8283}848586