Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editfield/PhabricatorEditField.php
| Show First 20 Lines • Show All 188 Lines • ▼ Show 20 Lines | public function readValueFromSubmit(AphrontRequest $request) { | ||||
| } else { | } else { | ||||
| $value = $this->getDefaultValue(); | $value = $this->getDefaultValue(); | ||||
| } | } | ||||
| $this->value = $value; | $this->value = $value; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| protected function getValueExistsInSubmit(AphrontRequest $request, $key) { | protected function getValueExistsInSubmit(AphrontRequest $request, $key) { | ||||
| return $request->getExists($key); | return $this->getHTTPParameterType()->getExists($request, $key); | ||||
| } | } | ||||
| protected function getValueFromSubmit(AphrontRequest $request, $key) { | protected function getValueFromSubmit(AphrontRequest $request, $key) { | ||||
| return $request->getStr($key); | return $this->getHTTPParameterType()->getValue($request, $key); | ||||
| } | } | ||||
| protected function getDefaultValue() { | protected function getDefaultValue() { | ||||
| return null; | return $this->getHTTPParameterType()->getDefaultValue(); | ||||
| } | } | ||||
| protected function getListFromRequest( | final public function getHTTPParameterType() { | ||||
| AphrontRequest $request, | $type = $this->newHTTPParameterType(); | ||||
| $key) { | |||||
| $list = $request->getArr($key, null); | |||||
| if ($list === null) { | |||||
| $list = $request->getStrList($key); | |||||
| } | |||||
| if (!$list) { | if ($type) { | ||||
| return array(); | $type->setViewer($this->getViewer()); | ||||
| } | } | ||||
| return $list; | return $type; | ||||
| } | } | ||||
| public function getHTTPParameterType() { | protected function newHTTPParameterType() { | ||||
| return 'string'; | return new AphrontStringHTTPParameterType(); | ||||
| } | } | ||||
| public function setEditTypeKey($edit_type_key) { | public function setEditTypeKey($edit_type_key) { | ||||
| $this->editTypeKey = $edit_type_key; | $this->editTypeKey = $edit_type_key; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getEditTypeKey() { | public function getEditTypeKey() { | ||||
| ▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | if (isset($edge_types[$transaction_type])) { | ||||
| $set, | $set, | ||||
| ); | ); | ||||
| } | } | ||||
| return array( | return array( | ||||
| id(new PhabricatorSimpleEditType()) | id(new PhabricatorSimpleEditType()) | ||||
| ->setEditType($type_key) | ->setEditType($type_key) | ||||
| ->setTransactionType($transaction_type) | ->setTransactionType($transaction_type) | ||||
| ->setValueType($this->getHTTPParameterType()) | ->setValueType($this->getHTTPParameterType()->getTypeName()) | ||||
| ->setDescription($this->getDescription()) | ->setDescription($this->getDescription()) | ||||
| ->setMetadata($this->metadata), | ->setMetadata($this->metadata), | ||||
| ); | ); | ||||
| } | } | ||||
| } | } | ||||