1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-03-02 07:29:25 +01:00
phorge-phorge/src/applications/diffusion/herald/DiffusionCommitAuthorPackagesHeraldField.php
epriestley c99485e8a0 Add "Author's Packages" and "Committer's Packages" Herald rules for Commits and Hooks
Summary: Fixes T13480. Adds the remaining missing Owners package rules for Herald commit adapters.

Test Plan: Created hooks which care about these fields, pushed commits, saw sensible transcript values.

Maniphest Tasks: T13480

Differential Revision: https://secure.phabricator.com/D20957
2020-01-29 15:52:07 -08:00

37 lines
853 B
PHP

<?php
final class DiffusionCommitAuthorPackagesHeraldField
extends DiffusionCommitHeraldField {
const FIELDCONST = 'diffusion.commit.author.packages';
public function getHeraldFieldName() {
return pht("Author's packages");
}
public function getHeraldFieldValue($object) {
$adapter = $this->getAdapter();
$viewer = $adapter->getViewer();
$author_phid = $adapter->getAuthorPHID();
if (!$author_phid) {
return array();
}
$packages = id(new PhabricatorOwnersPackageQuery())
->setViewer($viewer)
->withAuthorityPHIDs(array($author_phid))
->execute();
return mpull($packages, 'getPHID');
}
protected function getHeraldFieldStandardType() {
return self::STANDARD_PHID_LIST;
}
protected function getDatasource() {
return new PhabricatorOwnersPackageDatasource();
}
}