Differential D20957 Diff 49931 src/applications/diffusion/herald/DiffusionPreCommitContentAuthorPackagesHeraldField.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/herald/DiffusionPreCommitContentAuthorPackagesHeraldField.php
- This file was copied from src/applications/diffusion/herald/DiffusionPreCommitContentCommitterProjectsHeraldField.php.
<?php | <?php | ||||
final class DiffusionPreCommitContentCommitterProjectsHeraldField | final class DiffusionPreCommitContentAuthorPackagesHeraldField | ||||
extends DiffusionPreCommitContentHeraldField { | extends DiffusionPreCommitContentHeraldField { | ||||
const FIELDCONST = 'diffusion.pre.commit.committer.projects'; | const FIELDCONST = 'diffusion.pre.commit.author.packages'; | ||||
public function getHeraldFieldName() { | public function getHeraldFieldName() { | ||||
return pht("Committer's projects"); | return pht("Author's packages"); | ||||
} | } | ||||
public function getHeraldFieldValue($object) { | public function getHeraldFieldValue($object) { | ||||
$adapter = $this->getAdapter(); | $adapter = $this->getAdapter(); | ||||
$viewer = $adapter->getViewer(); | |||||
$phid = $adapter->getCommitterPHID(); | $author_phid = $adapter->getAuthorPHID(); | ||||
if (!$phid) { | if (!$author_phid) { | ||||
return array(); | return array(); | ||||
} | } | ||||
$viewer = $adapter->getViewer(); | $packages = id(new PhabricatorOwnersPackageQuery()) | ||||
$projects = id(new PhabricatorProjectQuery()) | |||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->withMemberPHIDs(array($phid)) | ->withAuthorityPHIDs(array($author_phid)) | ||||
->execute(); | ->execute(); | ||||
return mpull($projects, 'getPHID'); | return mpull($packages, 'getPHID'); | ||||
} | } | ||||
protected function getHeraldFieldStandardType() { | protected function getHeraldFieldStandardType() { | ||||
return self::STANDARD_PHID_LIST; | return self::STANDARD_PHID_LIST; | ||||
} | } | ||||
protected function getDatasource() { | protected function getDatasource() { | ||||
return new PhabricatorProjectDatasource(); | return new PhabricatorOwnersPackageDatasource(); | ||||
} | } | ||||
} | } |