Differential D20957 Diff 49931 src/applications/diffusion/herald/DiffusionPreCommitContentCommitterPackagesHeraldField.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/herald/DiffusionPreCommitContentCommitterPackagesHeraldField.php
- This file was copied from src/applications/diffusion/herald/DiffusionPreCommitContentCommitterProjectsHeraldField.php.
| <?php | <?php | ||||
| final class DiffusionPreCommitContentCommitterProjectsHeraldField | final class DiffusionPreCommitContentCommitterPackagesHeraldField | ||||
| extends DiffusionPreCommitContentHeraldField { | extends DiffusionPreCommitContentHeraldField { | ||||
| const FIELDCONST = 'diffusion.pre.commit.committer.projects'; | const FIELDCONST = 'diffusion.pre.commit.committer.packages'; | ||||
| public function getHeraldFieldName() { | public function getHeraldFieldName() { | ||||
| return pht("Committer's projects"); | return pht("Committer's packages"); | ||||
| } | } | ||||
| public function getHeraldFieldValue($object) { | public function getHeraldFieldValue($object) { | ||||
| $adapter = $this->getAdapter(); | $adapter = $this->getAdapter(); | ||||
| $viewer = $adapter->getViewer(); | |||||
| $phid = $adapter->getCommitterPHID(); | $committer_phid = $adapter->getCommitterPHID(); | ||||
| if (!$phid) { | if (!$committer_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($committer_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(); | ||||
| } | } | ||||
| } | } | ||||