Differential D20957 Diff 49931 src/applications/diffusion/herald/DiffusionPreCommitContentAuthorProjectsHeraldField.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/herald/DiffusionPreCommitContentAuthorProjectsHeraldField.php
| <?php | <?php | ||||
| final class DiffusionPreCommitContentAuthorProjectsHeraldField | final class DiffusionPreCommitContentAuthorProjectsHeraldField | ||||
| extends DiffusionPreCommitContentHeraldField { | extends DiffusionPreCommitContentHeraldField { | ||||
| const FIELDCONST = 'diffusion.pre.commit.author.projects'; | const FIELDCONST = 'diffusion.pre.commit.author.projects'; | ||||
| public function getHeraldFieldName() { | public function getHeraldFieldName() { | ||||
| return pht("Author's projects"); | return pht("Author's projects"); | ||||
| } | } | ||||
| public function getHeraldFieldValue($object) { | public function getHeraldFieldValue($object) { | ||||
| $adapter = $this->getAdapter(); | $adapter = $this->getAdapter(); | ||||
| $viewer = $adapter->getViewer(); | |||||
| $phid = $adapter->getAuthorPHID(); | $author_phid = $adapter->getAuthorPHID(); | ||||
| if (!$phid) { | if (!$author_phid) { | ||||
| return array(); | return array(); | ||||
| } | } | ||||
| $viewer = $adapter->getViewer(); | |||||
| $projects = id(new PhabricatorProjectQuery()) | $projects = id(new PhabricatorProjectQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->withMemberPHIDs(array($phid)) | ->withMemberPHIDs(array($author_phid)) | ||||
| ->execute(); | ->execute(); | ||||
| return mpull($projects, 'getPHID'); | return mpull($projects, '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 PhabricatorProjectDatasource(); | ||||
| } | } | ||||
| } | } | ||||