Summary: I like this abstraction better. Result of `phutil_implode_html()` may be also used as a param of `hsprintf()`. Test Plan: None. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4904
61 lines
1.4 KiB
PHP
61 lines
1.4 KiB
PHP
<?php
|
|
|
|
final class DifferentialCommitsFieldSpecification
|
|
extends DifferentialFieldSpecification {
|
|
|
|
public function shouldAppearOnRevisionView() {
|
|
return true;
|
|
}
|
|
|
|
public function getRequiredHandlePHIDsForRevisionView() {
|
|
return $this->getCommitPHIDs();
|
|
}
|
|
|
|
public function renderLabelForRevisionView() {
|
|
return 'Commits:';
|
|
}
|
|
|
|
public function renderValueForRevisionView() {
|
|
$commit_phids = $this->getCommitPHIDs();
|
|
if (!$commit_phids) {
|
|
return null;
|
|
}
|
|
|
|
$links = array();
|
|
foreach ($commit_phids as $commit_phid) {
|
|
$links[] = $this->getHandle($commit_phid)->renderLink();
|
|
}
|
|
|
|
return phutil_implode_html(phutil_tag('br'), $links);
|
|
}
|
|
|
|
private function getCommitPHIDs() {
|
|
$revision = $this->getRevision();
|
|
return $revision->getCommitPHIDs();
|
|
}
|
|
|
|
public function renderValueForMail($phase) {
|
|
$revision = $this->getRevision();
|
|
|
|
if ($revision->getStatus() != ArcanistDifferentialRevisionStatus::CLOSED) {
|
|
return null;
|
|
}
|
|
|
|
$phids = $revision->loadCommitPHIDs();
|
|
if (!$phids) {
|
|
return null;
|
|
}
|
|
|
|
$body = array();
|
|
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
|
|
$body[] = pht('COMMIT(S)', count($handles));
|
|
|
|
foreach ($handles as $handle) {
|
|
$body[] = ' '.PhabricatorEnv::getProductionURI($handle->getURI());
|
|
}
|
|
|
|
return implode("\n", $body);
|
|
}
|
|
|
|
}
|