Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/differential/customfield/DifferentialCustomField.php
12256 views
1
<?php
2
3
/**
4
* @task commitmessage Integration with Commit Messages
5
* @task diff Integration with Diff Properties
6
*/
7
abstract class DifferentialCustomField
8
extends PhabricatorCustomField {
9
10
/**
11
* TODO: It would be nice to remove this, but a lot of different code is
12
* bound together by it. Until everything is modernized, retaining the old
13
* field keys is the only reasonable way to update things one piece
14
* at a time.
15
*/
16
public function getFieldKeyForConduit() {
17
return $this->getFieldKey();
18
}
19
20
// TODO: As above.
21
public function getModernFieldKey() {
22
return $this->getFieldKeyForConduit();
23
}
24
25
protected function parseObjectList(
26
$value,
27
array $types,
28
$allow_partial = false,
29
array $suffixes = array()) {
30
return id(new PhabricatorObjectListQuery())
31
->setViewer($this->getViewer())
32
->setAllowedTypes($types)
33
->setObjectList($value)
34
->setAllowPartialResults($allow_partial)
35
->setSuffixes($suffixes)
36
->execute();
37
}
38
39
protected function renderObjectList(
40
array $handles,
41
array $suffixes = array()) {
42
43
if (!$handles) {
44
return null;
45
}
46
47
$out = array();
48
foreach ($handles as $handle) {
49
$phid = $handle->getPHID();
50
51
if ($handle->getPolicyFiltered()) {
52
$token = $phid;
53
} else if ($handle->isComplete()) {
54
$token = $handle->getCommandLineObjectName();
55
}
56
57
$suffix = idx($suffixes, $phid);
58
$token = $token.$suffix;
59
60
$out[] = $token;
61
}
62
63
return implode(', ', $out);
64
}
65
66
public function getWarningsForDetailView() {
67
if ($this->getProxy()) {
68
return $this->getProxy()->getWarningsForDetailView();
69
}
70
return array();
71
}
72
73
protected function getActiveDiff() {
74
$object = $this->getObject();
75
try {
76
return $object->getActiveDiff();
77
} catch (Exception $ex) {
78
return null;
79
}
80
}
81
82
public function getRequiredHandlePHIDsForRevisionHeaderWarnings() {
83
return array();
84
}
85
86
public function getWarningsForRevisionHeader(array $handles) {
87
return array();
88
}
89
90
91
/* -( Integration with Commit Messages )----------------------------------- */
92
93
94
/**
95
* @task commitmessage
96
*/
97
public function getProTips() {
98
if ($this->getProxy()) {
99
return $this->getProxy()->getProTips();
100
}
101
return array();
102
}
103
104
105
/* -( Integration with Diff Properties )----------------------------------- */
106
107
108
/**
109
* @task diff
110
*/
111
public function shouldAppearInDiffPropertyView() {
112
if ($this->getProxy()) {
113
return $this->getProxy()->shouldAppearInDiffPropertyView();
114
}
115
return false;
116
}
117
118
119
/**
120
* @task diff
121
*/
122
public function renderDiffPropertyViewLabel(DifferentialDiff $diff) {
123
if ($this->getProxy()) {
124
return $this->getProxy()->renderDiffPropertyViewLabel($diff);
125
}
126
return $this->getFieldName();
127
}
128
129
130
/**
131
* @task diff
132
*/
133
public function renderDiffPropertyViewValue(DifferentialDiff $diff) {
134
if ($this->getProxy()) {
135
return $this->getProxy()->renderDiffPropertyViewValue($diff);
136
}
137
throw new PhabricatorCustomFieldImplementationIncompleteException($this);
138
}
139
140
}
141
142