1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-02 11:42:42 +01:00
phorge-phorge/src/applications/diffusion/engineextension/DiffusionHovercardEngineExtension.php
epriestley bae8a95114 Continue replacing Commit/Audit status checks with object-based checks
Summary: Ref T13195. See PHI851. Continuing down the path toward replacing these legacy numeric constants with more modern string constants.

Test Plan:
- Raised concern, requested verification, verified.
- Looked at commit hovercard with audit status.
- Viewed header on a commit page.
- (Didn't test the Doorkeeper stuff since it requires linking to Asana and seems unlikely to break.)

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13195

Differential Revision: https://secure.phabricator.com/D19647
2018-09-10 11:20:31 -07:00

53 lines
1.3 KiB
PHP

<?php
final class DiffusionHovercardEngineExtension
extends PhabricatorHovercardEngineExtension {
const EXTENSIONKEY = 'diffusion';
public function isExtensionEnabled() {
return PhabricatorApplication::isClassInstalled(
'PhabricatorDiffusionApplication');
}
public function getExtensionName() {
return pht('Diffusion Commits');
}
public function canRenderObjectHovercard($object) {
return ($object instanceof PhabricatorRepositoryCommit);
}
public function renderHovercard(
PHUIHovercardView $hovercard,
PhabricatorObjectHandle $handle,
$commit,
$data) {
$viewer = $this->getViewer();
$author_phid = $commit->getAuthorPHID();
if ($author_phid) {
$author = $viewer->renderHandle($author_phid);
} else {
$commit_data = $commit->loadCommitData();
$author = phutil_tag('em', array(), $commit_data->getAuthorName());
}
$hovercard->setTitle($handle->getName());
$hovercard->setDetail($commit->getSummary());
$hovercard->addField(pht('Author'), $author);
$hovercard->addField(pht('Date'),
phabricator_date($commit->getEpoch(), $viewer));
if (!$commit->isAuditStatusNoAudit()) {
$status = $commit->getAuditStatusObject();
$hovercard->addField(
pht('Audit Status'),
$status->getName());
}
}
}