2011-02-08 19:53:59 +01:00
|
|
|
<?php
|
|
|
|
|
2011-07-04 22:04:22 +02:00
|
|
|
final class ManiphestTaskPriority extends ManiphestConstants {
|
2011-02-08 19:53:59 +01:00
|
|
|
|
2012-08-01 07:52:46 +02:00
|
|
|
/**
|
|
|
|
* Get the priorities and their full descriptions.
|
|
|
|
*
|
|
|
|
* @return map Priorities to descriptions.
|
|
|
|
*/
|
2011-02-08 19:53:59 +01:00
|
|
|
public static function getTaskPriorityMap() {
|
2013-09-13 20:11:05 +02:00
|
|
|
$map = self::getConfig();
|
|
|
|
foreach ($map as $key => $spec) {
|
|
|
|
$map[$key] = idx($spec, 'name', $key);
|
|
|
|
}
|
|
|
|
return $map;
|
2011-02-08 19:53:59 +01:00
|
|
|
}
|
|
|
|
|
2013-09-13 20:11:05 +02:00
|
|
|
|
2012-08-01 07:52:46 +02:00
|
|
|
/**
|
|
|
|
* Get the priorities and their related short (one-word) descriptions.
|
|
|
|
*
|
2013-09-13 20:11:05 +02:00
|
|
|
* @return map Priorities to short descriptions.
|
2012-08-01 07:52:46 +02:00
|
|
|
*/
|
2013-09-13 20:11:05 +02:00
|
|
|
public static function getShortNameMap() {
|
|
|
|
$map = self::getConfig();
|
|
|
|
foreach ($map as $key => $spec) {
|
|
|
|
$map[$key] = idx($spec, 'short', idx($spec, 'name', $key));
|
|
|
|
}
|
|
|
|
return $map;
|
2012-03-20 03:46:57 +01:00
|
|
|
}
|
|
|
|
|
2013-09-13 20:11:05 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a map from priority constants to their colors.
|
|
|
|
*
|
|
|
|
* @return map<int, string> Priorities to colors.
|
|
|
|
*/
|
|
|
|
public static function getColorMap() {
|
|
|
|
$map = self::getConfig();
|
|
|
|
foreach ($map as $key => $spec) {
|
|
|
|
$map[$key] = idx($spec, 'color', 'grey');
|
|
|
|
}
|
|
|
|
return $map;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-04 23:19:37 +02:00
|
|
|
/**
|
|
|
|
* Return the default priority for this instance of Phabricator.
|
|
|
|
*
|
|
|
|
* @return int The value of the default priority constant.
|
|
|
|
*/
|
|
|
|
public static function getDefaultPriority() {
|
2013-09-13 19:24:46 +02:00
|
|
|
return PhabricatorEnv::getEnvConfig('maniphest.default-priority');
|
2012-10-04 23:19:37 +02:00
|
|
|
}
|
2012-08-01 07:52:46 +02:00
|
|
|
|
2013-09-13 20:11:05 +02:00
|
|
|
|
2012-08-01 07:52:46 +02:00
|
|
|
/**
|
|
|
|
* Retrieve the full name of the priority level provided.
|
|
|
|
*
|
|
|
|
* @param int A priority level.
|
2013-09-13 20:11:05 +02:00
|
|
|
* @return string The priority name if the level is a valid one.
|
2012-08-01 07:52:46 +02:00
|
|
|
*/
|
2011-02-08 19:53:59 +01:00
|
|
|
public static function getTaskPriorityName($priority) {
|
2013-09-13 20:11:05 +02:00
|
|
|
return idx(self::getTaskPriorityMap(), $priority, $priority);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static function getConfig() {
|
|
|
|
$config = PhabricatorEnv::getEnvConfig('maniphest.priorities');
|
|
|
|
krsort($config);
|
|
|
|
return $config;
|
2011-02-08 19:53:59 +01:00
|
|
|
}
|
2012-10-04 23:19:37 +02:00
|
|
|
|
2011-02-08 19:53:59 +01:00
|
|
|
}
|