Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editfield/PhabricatorEditField.php
| Show First 20 Lines • Show All 293 Lines • ▼ Show 20 Lines | abstract class PhabricatorEditField extends Phobject { | ||||
| } | } | ||||
| public function setTransactionType($type) { | public function setTransactionType($type) { | ||||
| $this->transactionType = $type; | $this->transactionType = $type; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function readValueFromRequest(AphrontRequest $request) { | public function readValueFromRequest(AphrontRequest $request) { | ||||
| $check = array_merge(array($this->getKey()), $this->getAliases()); | $check = $this->getAllReadValueFromRequestKeys(); | ||||
| foreach ($check as $key) { | foreach ($check as $key) { | ||||
| if (!$this->getValueExistsInRequest($request, $key)) { | if (!$this->getValueExistsInRequest($request, $key)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| $this->value = $this->getValueFromRequest($request, $key); | $this->value = $this->getValueFromRequest($request, $key); | ||||
| return; | break; | ||||
| } | |||||
| return $this; | |||||
| } | } | ||||
| $this->readValueFromObject($this->getObject()); | public function getAllReadValueFromRequestKeys() { | ||||
| $keys = array(); | |||||
| return $this; | $keys[] = $this->getKey(); | ||||
| foreach ($this->getAliases() as $alias) { | |||||
| $keys[] = $alias; | |||||
| } | } | ||||
| public function readValueFromObject($object) { | return $keys; | ||||
| $this->value = $this->getValueFromObject($object); | |||||
| return $this; | |||||
| } | } | ||||
| public function readDefaultValueFromConfiguration($value) { | public function readDefaultValueFromConfiguration($value) { | ||||
| $this->value = $this->getDefaultValueFromConfiguration($value); | $this->value = $this->getDefaultValueFromConfiguration($value); | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| protected function getDefaultValueFromConfiguration($value) { | protected function getDefaultValueFromConfiguration($value) { | ||||
| return $value; | return $value; | ||||
| } | } | ||||
| protected function getValueFromObject($object) { | protected function getValueFromObject($object) { | ||||
| if ($this->hasValue) { | if ($this->hasValue) { | ||||
| return $this->value; | return $this->value; | ||||
| } else { | } else { | ||||
| return $this->getDefaultValue(); | return $this->getDefaultValue(); | ||||
| } | } | ||||
| } | } | ||||
| protected function getValueExistsInRequest(AphrontRequest $request, $key) { | protected function getValueExistsInRequest(AphrontRequest $request, $key) { | ||||
| return $this->getValueExistsInSubmit($request, $key); | return $this->getHTTPParameterValueExists($request, $key); | ||||
| } | } | ||||
| protected function getValueFromRequest(AphrontRequest $request, $key) { | protected function getValueFromRequest(AphrontRequest $request, $key) { | ||||
| return $this->getValueFromSubmit($request, $key); | return $this->getHTTPParameterValue($request, $key); | ||||
| } | } | ||||
| /** | /** | ||||
| * Read and return the value the object had when the user first loaded the | * Read and return the value the object had when the user first loaded the | ||||
| * form. | * form. | ||||
| * | * | ||||
| * This is the initial value from the user's point of view when they started | * This is the initial value from the user's point of view when they started | ||||
| Show All 27 Lines | public function readValueFromSubmit(AphrontRequest $request) { | ||||
| $initial_value = $this->getInitialValueFromSubmit($request, $key); | $initial_value = $this->getInitialValueFromSubmit($request, $key); | ||||
| $this->initialValue = $initial_value; | $this->initialValue = $initial_value; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| protected function getValueExistsInSubmit(AphrontRequest $request, $key) { | protected function getValueExistsInSubmit(AphrontRequest $request, $key) { | ||||
| return $this->getHTTPParameterValueExists($request, $key); | |||||
| } | |||||
| protected function getValueFromSubmit(AphrontRequest $request, $key) { | |||||
| return $this->getHTTPParameterValue($request, $key); | |||||
| } | |||||
| protected function getHTTPParameterValueExists( | |||||
| AphrontRequest $request, | |||||
| $key) { | |||||
| $type = $this->getHTTPParameterType(); | $type = $this->getHTTPParameterType(); | ||||
| if ($type) { | if ($type) { | ||||
| return $type->getExists($request, $key); | return $type->getExists($request, $key); | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| protected function getValueFromSubmit(AphrontRequest $request, $key) { | protected function getHTTPParameterValue($request, $key) { | ||||
| return $this->getHTTPParameterType()->getValue($request, $key); | $type = $this->getHTTPParameterType(); | ||||
| if ($type) { | |||||
| return $type->getValue($request, $key); | |||||
| } | |||||
| return null; | |||||
| } | } | ||||
| protected function getDefaultValue() { | protected function getDefaultValue() { | ||||
| $type = $this->getHTTPParameterType(); | $type = $this->getHTTPParameterType(); | ||||
| if ($type) { | if ($type) { | ||||
| return $type->getDefaultValue(); | return $type->getDefaultValue(); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 72 Lines • Show Last 20 Lines | |||||