Page MenuHomePhabricator
Paste P1947

WarningCustomField.php
ActivePublic

Authored by epriestley on Feb 23 2016, 4:15 PM.
Tags
None
Referenced Files
F1125788: WarningCustomField.php
Feb 23 2016, 4:15 PM
Subscribers
None
<?php
final class WarningCustomField extends DifferentialCustomField {
public function getFieldKey() {
return 'mycompany:mycustomfield';
}
public function shouldAppearInPropertyView() {
// This is required or the field won't be loaded on the detail page.
return true;
}
public function renderPropertyViewValue(array $handles) {
// This prevents it from actually rendering a property.
return null;
}
public function getWarningsForRevisionHeader(array $handles) {
$revision = $this->getObject();
// Do some magic here to figure out if the branch the revision will land
// onto is bad.
$is_bad = some_magic($revision);
$warnings = array();
if ($is_bad) {
$warnings[] = pht(
'IMPORTANT! The branch this revision is targeting has a broken '.
'build!');
}
return $warnings;
}
}