@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class DifferentialLegacyQuery
4 extends Phobject {
5
6 const STATUS_ANY = 'status-any';
7 const STATUS_OPEN = 'status-open';
8 const STATUS_ACCEPTED = 'status-accepted';
9 const STATUS_NEEDS_REVIEW = 'status-needs-review';
10 const STATUS_NEEDS_REVISION = 'status-needs-revision';
11 const STATUS_CLOSED = 'status-closed';
12 const STATUS_ABANDONED = 'status-abandoned';
13
14 public static function getAllConstants() {
15 return array_keys(self::getMap());
16 }
17
18 public static function getModernValues($status) {
19 if ($status === self::STATUS_ANY) {
20 return null;
21 }
22
23 $map = self::getMap();
24 if (!isset($map[$status])) {
25 throw new Exception(
26 pht(
27 'Unknown revision status filter constant "%s".',
28 $status));
29 }
30
31 return $map[$status];
32 }
33
34 private static function getMap() {
35 $all = array_keys(DifferentialRevisionStatus::getAll());
36
37 $open = array();
38 $closed = array();
39
40 foreach ($all as $status) {
41 $status_object = DifferentialRevisionStatus::newForStatus($status);
42 if ($status_object->isClosedStatus()) {
43 $closed[] = $status_object->getKey();
44 } else {
45 $open[] = $status_object->getKey();
46 }
47 }
48
49 return array(
50 self::STATUS_ANY => $all,
51 self::STATUS_OPEN => $open,
52 self::STATUS_ACCEPTED => array(
53 DifferentialRevisionStatus::ACCEPTED,
54 ),
55 self::STATUS_NEEDS_REVIEW => array(
56 DifferentialRevisionStatus::NEEDS_REVIEW,
57
58 // For legacy callers, "Draft" is treated as "Needs Review".
59 DifferentialRevisionStatus::DRAFT,
60 ),
61 self::STATUS_NEEDS_REVISION => array(
62 DifferentialRevisionStatus::NEEDS_REVISION,
63 ),
64 self::STATUS_CLOSED => $closed,
65 self::STATUS_ABANDONED => array(
66 DifferentialRevisionStatus::ABANDONED,
67 ),
68 );
69 }
70
71}