3 final class PhabricatorCustomFieldEditField
4 extends PhabricatorEditField
{
7 private $httpParameterType;
8 private $conduitParameterType;
9 private $bulkParameterType;
10 private $commentAction;
12 public function setCustomField(PhabricatorCustomField
$custom_field) {
13 $this->customField
= $custom_field;
17 public function getCustomField() {
18 return $this->customField
;
21 public function setCustomFieldHTTPParameterType(
22 AphrontHTTPParameterType
$type) {
23 $this->httpParameterType
= $type;
27 public function getCustomFieldHTTPParameterType() {
28 return $this->httpParameterType
;
31 public function setCustomFieldConduitParameterType(
32 ConduitParameterType
$type) {
33 $this->conduitParameterType
= $type;
37 public function getCustomFieldConduitParameterType() {
38 return $this->conduitParameterType
;
41 public function setCustomFieldBulkParameterType(
42 BulkParameterType
$type) {
43 $this->bulkParameterType
= $type;
47 public function getCustomFieldBulkParameterType() {
48 return $this->bulkParameterType
;
51 public function setCustomFieldCommentAction(
52 PhabricatorEditEngineCommentAction
$comment_action) {
53 $this->commentAction
= $comment_action;
57 public function getCustomFieldCommentAction() {
58 return $this->commentAction
;
61 protected function buildControl() {
62 if (!$this->getIsFormField()) {
66 $field = $this->getCustomField();
67 $clone = clone $field;
69 $value = $this->getValue();
70 $clone->setValueFromApplicationTransactions($value);
72 return $clone->renderEditControl(array());
75 protected function newEditType() {
76 return id(new PhabricatorCustomFieldEditType())
77 ->setCustomField($this->getCustomField());
80 public function getValueForTransaction() {
81 $value = $this->getValue();
82 $field = $this->getCustomField();
84 // Avoid changing the value of the field itself, since later calls would
85 // incorrectly reflect the new value.
86 $clone = clone $field;
87 $clone->setValueFromApplicationTransactions($value);
88 return $clone->getNewValueForApplicationTransactions();
91 protected function getValueForCommentAction($value) {
92 $field = $this->getCustomField();
93 $clone = clone $field;
94 $clone->setValueFromApplicationTransactions($value);
96 // TODO: This is somewhat bogus because only StandardCustomFields
97 // implement a getFieldValue() method -- not all CustomFields. Today,
98 // only StandardCustomFields can ever actually generate a comment action
99 // so we never reach this method with other field types.
101 return $clone->getFieldValue();
104 protected function getValueExistsInSubmit(AphrontRequest
$request, $key) {
108 protected function getValueFromSubmit(AphrontRequest
$request, $key) {
109 $field = $this->getCustomField();
111 $clone = clone $field;
113 $clone->readValueFromRequest($request);
114 return $clone->getNewValueForApplicationTransactions();
117 protected function newConduitEditTypes() {
118 $field = $this->getCustomField();
120 if (!$field->shouldAppearInConduitTransactions()) {
124 return parent
::newConduitEditTypes();
127 protected function newHTTPParameterType() {
128 $type = $this->getCustomFieldHTTPParameterType();
137 protected function newCommentAction() {
138 $action = $this->getCustomFieldCommentAction();
141 return clone $action;
147 protected function newConduitParameterType() {
148 $type = $this->getCustomFieldConduitParameterType();
157 protected function newBulkParameterType() {
158 $type = $this->getCustomFieldBulkParameterType();
167 public function getAllReadValueFromRequestKeys() {
170 // NOTE: This piece of complexity is so we can expose a reasonable key in
171 // the UI ("custom.x") instead of a crufty internal key ("std:app:x").
172 // Perhaps we can simplify this some day.
174 // In the parent, this is just getKey(), but that returns a cumbersome
175 // key in EditFields. Use the simpler edit type key instead.
176 $keys[] = $this->getEditTypeKey();
178 foreach ($this->getAliases() as $alias) {