Differential D18343 Diff 44161 src/applications/differential/constants/DifferentialRevisionStatus.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/constants/DifferentialRevisionStatus.php
| <?php | <?php | ||||
| final class DifferentialRevisionStatus extends Phobject { | final class DifferentialRevisionStatus extends Phobject { | ||||
| const NEEDS_REVIEW = 'needs-review'; | const NEEDS_REVIEW = 'needs-review'; | ||||
| const NEEDS_REVISION = 'needs-revision'; | const NEEDS_REVISION = 'needs-revision'; | ||||
| const CHANGES_PLANNED = 'changes-planned'; | const CHANGES_PLANNED = 'changes-planned'; | ||||
| const ACCEPTED = 'accepted'; | const ACCEPTED = 'accepted'; | ||||
| const PUBLISHED = 'published'; | const PUBLISHED = 'published'; | ||||
| const ABANDONED = 'abandoned'; | const ABANDONED = 'abandoned'; | ||||
| private $key; | private $key; | ||||
| private $spec = array(); | private $spec = array(); | ||||
| public function getKey() { | |||||
| return $this->key; | |||||
| } | |||||
| public function getLegacyKey() { | |||||
| return idx($this->spec, 'legacy'); | |||||
| } | |||||
| public function getIcon() { | public function getIcon() { | ||||
| return idx($this->spec, 'icon'); | return idx($this->spec, 'icon'); | ||||
| } | } | ||||
| public function getIconColor() { | public function getIconColor() { | ||||
| return idx($this->spec, 'color.icon', 'bluegrey'); | return idx($this->spec, 'color.icon', 'bluegrey'); | ||||
| } | } | ||||
| Show All 24 Lines | final class DifferentialRevisionStatus extends Phobject { | ||||
| public function isPublished() { | public function isPublished() { | ||||
| return ($this->key === self::PUBLISHED); | return ($this->key === self::PUBLISHED); | ||||
| } | } | ||||
| public function isChangePlanned() { | public function isChangePlanned() { | ||||
| return ($this->key === self::CHANGES_PLANNED); | return ($this->key === self::CHANGES_PLANNED); | ||||
| } | } | ||||
| public static function newForStatus($status) { | |||||
| $result = new self(); | |||||
| $map = self::getMap(); | |||||
| if (isset($map[$status])) { | |||||
| $result->key = $status; | |||||
| $result->spec = $map[$status]; | |||||
| } | |||||
| return $result; | |||||
| } | |||||
| public static function newForLegacyStatus($legacy_status) { | public static function newForLegacyStatus($legacy_status) { | ||||
| $result = new self(); | $result = new self(); | ||||
| $map = self::getMap(); | $map = self::getMap(); | ||||
| foreach ($map as $key => $spec) { | foreach ($map as $key => $spec) { | ||||
| if (!isset($spec['legacy'])) { | if (!isset($spec['legacy'])) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | return array( | ||||
| 'closed' => true, | 'closed' => true, | ||||
| 'color.icon' => 'black', | 'color.icon' => 'black', | ||||
| 'color.tag' => 'indigo', | 'color.tag' => 'indigo', | ||||
| 'color.ansi' => null, | 'color.ansi' => null, | ||||
| ), | ), | ||||
| ); | ); | ||||
| } | } | ||||
| public static function getClosedStatuses() { | |||||
| $statuses = array( | |||||
| ArcanistDifferentialRevisionStatus::CLOSED, | |||||
| ArcanistDifferentialRevisionStatus::ABANDONED, | |||||
| ); | |||||
| if (PhabricatorEnv::getEnvConfig('differential.close-on-accept')) { | |||||
| $statuses[] = ArcanistDifferentialRevisionStatus::ACCEPTED; | |||||
| } | |||||
| return $statuses; | |||||
| } | |||||
| public static function getOpenStatuses() { | |||||
| return array_diff(self::getAllStatuses(), self::getClosedStatuses()); | |||||
| } | |||||
| public static function getAllStatuses() { | |||||
| return array( | |||||
| ArcanistDifferentialRevisionStatus::NEEDS_REVIEW, | |||||
| ArcanistDifferentialRevisionStatus::NEEDS_REVISION, | |||||
| ArcanistDifferentialRevisionStatus::CHANGES_PLANNED, | |||||
| ArcanistDifferentialRevisionStatus::ACCEPTED, | |||||
| ArcanistDifferentialRevisionStatus::CLOSED, | |||||
| ArcanistDifferentialRevisionStatus::ABANDONED, | |||||
| ArcanistDifferentialRevisionStatus::IN_PREPARATION, | |||||
| ); | |||||
| } | |||||
| } | } | ||||