@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 DiffusionCommitAuditorsHeraldField
4 extends DiffusionCommitHeraldField {
5
6 const FIELDCONST = 'diffusion.commit.auditors';
7
8 // hide "Auditors" Herald condition if Audit is disabled
9 public function supportsObject($object) {
10 if (id(new PhabricatorAuditApplication())->isInstalled()) {
11 return ($object instanceof PhabricatorRepositoryCommit);
12 } else {
13 return false;
14 }
15 }
16
17 public function getHeraldFieldName() {
18 return pht('Auditors');
19 }
20
21 public function getHeraldFieldValue($object) {
22 $viewer = PhabricatorUser::getOmnipotentUser();
23
24 $commit = id(new DiffusionCommitQuery())
25 ->setViewer($viewer)
26 ->withPHIDs(array($object->getPHID()))
27 ->needAuditRequests(true)
28 ->executeOne();
29
30 $audits = $commit->getAudits();
31
32 $phids = array();
33 foreach ($audits as $audit) {
34 if ($audit->isResigned()) {
35 continue;
36 }
37
38 $phids[] = $audit->getAuditorPHID();
39 }
40
41 return $phids;
42 }
43
44 protected function getHeraldFieldStandardType() {
45 return self::STANDARD_PHID_LIST;
46 }
47
48 protected function getDatasource() {
49 return new DiffusionAuditorDatasource();
50 }
51
52}