@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class DifferentialTestPlanField
4 extends DifferentialCoreCustomField {
5
6 public function getFieldKey() {
7 return 'differential:test-plan';
8 }
9
10 public function getFieldName() {
11 return pht('Test Plan');
12 }
13
14 public function getFieldDescription() {
15 return pht('Actions performed to verify the behavior of the change.');
16 }
17
18 protected function readValueFromRevision(
19 DifferentialRevision $revision) {
20 if (!$revision->getID()) {
21 return null;
22 }
23 return $revision->getTestPlan();
24 }
25
26 public function canDisableField() {
27 return true;
28 }
29
30 public function shouldAppearInGlobalSearch() {
31 return true;
32 }
33
34 public function updateAbstractDocument(
35 PhabricatorSearchAbstractDocument $document) {
36 if (strlen($this->getValue())) {
37 $document->addField('plan', $this->getValue());
38 }
39 }
40
41 public function shouldAppearInPropertyView() {
42 return true;
43 }
44
45 public function renderPropertyViewLabel() {
46 return $this->getFieldName();
47 }
48
49 public function getStyleForPropertyView() {
50 return 'block';
51 }
52
53 public function getIconForPropertyView() {
54 return PHUIPropertyListView::ICON_TESTPLAN;
55 }
56
57 public function renderPropertyViewValue(array $handles) {
58 if (!strlen($this->getValue())) {
59 return null;
60 }
61
62 return new PHUIRemarkupView($this->getViewer(), $this->getValue());
63 }
64
65 public function shouldAppearInTransactionMail() {
66 return true;
67 }
68
69 public function updateTransactionMailBody(
70 PhabricatorMetaMTAMailBody $body,
71 PhabricatorApplicationTransactionEditor $editor,
72 array $xactions) {
73
74 if (!$editor->isFirstBroadcast()) {
75 return;
76 }
77
78 $test_plan = $this->getValue();
79 if (!strlen(trim($test_plan))) {
80 return;
81 }
82
83 $body->addRemarkupSection(pht('TEST PLAN'), $test_plan);
84 }
85
86
87}