Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / infrastructure / customfield / editor / PhabricatorCustomFieldEditField.php
blob1a63e040e2bdc06e713f012361cf99e0ecbdfe8d
1 <?php
3 final class PhabricatorCustomFieldEditField
4 extends PhabricatorEditField {
6 private $customField;
7 private $httpParameterType;
8 private $conduitParameterType;
9 private $bulkParameterType;
10 private $commentAction;
12 public function setCustomField(PhabricatorCustomField $custom_field) {
13 $this->customField = $custom_field;
14 return $this;
17 public function getCustomField() {
18 return $this->customField;
21 public function setCustomFieldHTTPParameterType(
22 AphrontHTTPParameterType $type) {
23 $this->httpParameterType = $type;
24 return $this;
27 public function getCustomFieldHTTPParameterType() {
28 return $this->httpParameterType;
31 public function setCustomFieldConduitParameterType(
32 ConduitParameterType $type) {
33 $this->conduitParameterType = $type;
34 return $this;
37 public function getCustomFieldConduitParameterType() {
38 return $this->conduitParameterType;
41 public function setCustomFieldBulkParameterType(
42 BulkParameterType $type) {
43 $this->bulkParameterType = $type;
44 return $this;
47 public function getCustomFieldBulkParameterType() {
48 return $this->bulkParameterType;
51 public function setCustomFieldCommentAction(
52 PhabricatorEditEngineCommentAction $comment_action) {
53 $this->commentAction = $comment_action;
54 return $this;
57 public function getCustomFieldCommentAction() {
58 return $this->commentAction;
61 protected function buildControl() {
62 if (!$this->getIsFormField()) {
63 return null;
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) {
105 return true;
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()) {
121 return array();
124 return parent::newConduitEditTypes();
127 protected function newHTTPParameterType() {
128 $type = $this->getCustomFieldHTTPParameterType();
130 if ($type) {
131 return clone $type;
134 return null;
137 protected function newCommentAction() {
138 $action = $this->getCustomFieldCommentAction();
140 if ($action) {
141 return clone $action;
144 return null;
147 protected function newConduitParameterType() {
148 $type = $this->getCustomFieldConduitParameterType();
150 if ($type) {
151 return clone $type;
154 return null;
157 protected function newBulkParameterType() {
158 $type = $this->getCustomFieldBulkParameterType();
160 if ($type) {
161 return clone $type;
164 return null;
167 public function getAllReadValueFromRequestKeys() {
168 $keys = array();
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) {
179 $keys[] = $alias;
182 return $keys;