1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-03 20:22:46 +01:00
phorge-phorge/src/applications/diffusion/herald/DiffusionCommitAuditorsHeraldField.php
epriestley 545dad319e Add an "Auditors" rule for Commits
Summary: Fixes T5889. You can't write a rule like "if no other Herald rules did anything...", but you can use this rule to check for Owners or an explicit "Auditors" field doing things.

Test Plan: Using the test console, ran an "Auditors" rule against a commit with and without an auditor. Got expected pass/fail outcomes.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T5889

Differential Revision: https://secure.phabricator.com/D17221
2017-01-18 10:05:30 -08:00

41 lines
892 B
PHP

<?php
final class DiffusionCommitAuditorsHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.auditors';
public function getHeraldFieldName() {
return pht('Auditors');
}
public function getHeraldFieldValue($object) {
$viewer = PhabricatorUser::getOmnipotentUser();
$commit = id(new DiffusionCommitQuery())
->setViewer($viewer)
->withPHIDs(array($object->getPHID()))
->needAuditRequests(true)
->executeOne();
$audits = $commit->getAudits();
$phids = array();
foreach ($audits as $audit) {
if ($audit->isActiveAudit()) {
$phids[] = $audit->getAuditorPHID();
}
}
return $phids;
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new DiffusionAuditorDatasource();
}
}