@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 DifferentialBlameRevisionField
4 extends DifferentialStoredCustomField {
5
6 public function getFieldKey() {
7 return 'phabricator:blame-revision';
8 }
9
10 public function getFieldKeyForConduit() {
11 return 'blameRevision';
12 }
13
14 public function getFieldName() {
15 return pht('Blame Revision');
16 }
17
18 public function getFieldDescription() {
19 return pht('Stores a reference to what this fixes.');
20 }
21
22 public function shouldDisableByDefault() {
23 return true;
24 }
25
26 public function shouldAppearInPropertyView() {
27 return true;
28 }
29
30 public function renderPropertyViewLabel() {
31 return $this->getFieldName();
32 }
33
34 public function renderPropertyViewValue(array $handles) {
35 if (!strlen($this->getValue())) {
36 return null;
37 }
38
39 return $this->getValue();
40 }
41
42 public function shouldAppearInEditView() {
43 return true;
44 }
45
46 public function shouldAppearInApplicationTransactions() {
47 return true;
48 }
49
50 public function getOldValueForApplicationTransactions() {
51 return $this->getValue();
52 }
53
54 public function getNewValueForApplicationTransactions() {
55 return $this->getValue();
56 }
57
58 public function readValueFromRequest(AphrontRequest $request) {
59 $this->setValue($request->getStr($this->getFieldKey()));
60 }
61
62 public function renderEditControl(array $handles) {
63 return id(new AphrontFormTextControl())
64 ->setName($this->getFieldKey())
65 ->setValue($this->getValue())
66 ->setLabel($this->getFieldName());
67 }
68
69 public function getApplicationTransactionTitle(
70 PhabricatorApplicationTransaction $xaction) {
71 $author_phid = $xaction->getAuthorPHID();
72 $old = $xaction->getOldValue();
73 $new = $xaction->getNewValue();
74
75 return pht(
76 '%s updated the blame revision for this revision.',
77 $xaction->renderHandleLink($author_phid));
78 }
79
80 public function getApplicationTransactionTitleForFeed(
81 PhabricatorApplicationTransaction $xaction) {
82
83 $object_phid = $xaction->getObjectPHID();
84 $author_phid = $xaction->getAuthorPHID();
85 $old = $xaction->getOldValue();
86 $new = $xaction->getNewValue();
87
88 return pht(
89 '%s updated the blame revision for %s.',
90 $xaction->renderHandleLink($author_phid),
91 $xaction->renderHandleLink($object_phid));
92 }
93
94 public function shouldAppearInConduitDictionary() {
95 return true;
96 }
97
98 public function shouldAppearInConduitTransactions() {
99 return true;
100 }
101
102 protected function newConduitEditParameterType() {
103 return new ConduitStringParameterType();
104 }
105
106}