Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/people/customfield/PhabricatorUserBlurbField.php
12256 views
1
<?php
2
3
final class PhabricatorUserBlurbField
4
extends PhabricatorUserCustomField {
5
6
private $value;
7
8
public function getFieldKey() {
9
return 'user:blurb';
10
}
11
12
public function getModernFieldKey() {
13
return 'blurb';
14
}
15
16
public function getFieldKeyForConduit() {
17
return $this->getModernFieldKey();
18
}
19
20
public function getFieldName() {
21
return pht('Blurb');
22
}
23
24
public function getFieldDescription() {
25
return pht('Short blurb about the user.');
26
}
27
28
public function shouldAppearInApplicationTransactions() {
29
return true;
30
}
31
32
public function shouldAppearInEditView() {
33
return true;
34
}
35
36
public function shouldAppearInPropertyView() {
37
return true;
38
}
39
40
public function readValueFromObject(PhabricatorCustomFieldInterface $object) {
41
$this->value = $object->loadUserProfile()->getBlurb();
42
}
43
44
public function getOldValueForApplicationTransactions() {
45
return $this->getObject()->loadUserProfile()->getBlurb();
46
}
47
48
public function getNewValueForApplicationTransactions() {
49
return $this->value;
50
}
51
52
public function applyApplicationTransactionInternalEffects(
53
PhabricatorApplicationTransaction $xaction) {
54
$this->getObject()->loadUserProfile()->setBlurb($xaction->getNewValue());
55
}
56
57
public function readValueFromRequest(AphrontRequest $request) {
58
$this->value = $request->getStr($this->getFieldKey());
59
}
60
61
public function setValueFromStorage($value) {
62
$this->value = $value;
63
return $this;
64
}
65
66
public function renderEditControl(array $handles) {
67
return id(new PhabricatorRemarkupControl())
68
->setUser($this->getViewer())
69
->setName($this->getFieldKey())
70
->setValue($this->value)
71
->setLabel($this->getFieldName());
72
}
73
74
public function getApplicationTransactionRemarkupBlocks(
75
PhabricatorApplicationTransaction $xaction) {
76
return array(
77
$xaction->getNewValue(),
78
);
79
}
80
81
public function renderPropertyViewLabel() {
82
return null;
83
}
84
85
public function renderPropertyViewValue(array $handles) {
86
$blurb = $this->getObject()->loadUserProfile()->getBlurb();
87
if (!strlen($blurb)) {
88
return null;
89
}
90
91
$viewer = $this->getViewer();
92
$view = new PHUIRemarkupView($viewer, $blurb);
93
94
return $view;
95
}
96
97
public function getStyleForPropertyView() {
98
return 'block';
99
}
100
101
public function shouldAppearInConduitTransactions() {
102
return true;
103
}
104
105
protected function newConduitEditParameterType() {
106
return new ConduitStringParameterType();
107
}
108
109
}
110
111