Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editfield/PhabricatorEditField.php
| <?php | <?php | ||||
| abstract class PhabricatorEditField extends Phobject { | abstract class PhabricatorEditField extends Phobject { | ||||
| private $key; | private $key; | ||||
| private $viewer; | private $viewer; | ||||
| private $label; | private $label; | ||||
| private $aliases = array(); | private $aliases = array(); | ||||
| private $value; | private $value; | ||||
| private $hasValue = false; | private $hasValue = false; | ||||
| private $object; | private $object; | ||||
| private $transactionType; | private $transactionType; | ||||
| private $metadata = array(); | private $metadata = array(); | ||||
| private $description; | private $description; | ||||
| private $editTypeKey; | private $editTypeKey; | ||||
| private $isLocked; | |||||
| public function setKey($key) { | public function setKey($key) { | ||||
| $this->key = $key; | $this->key = $key; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getKey() { | public function getKey() { | ||||
| return $this->key; | return $this->key; | ||||
| Show All 39 Lines | public function setDescription($description) { | ||||
| $this->description = $description; | $this->description = $description; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getDescription() { | public function getDescription() { | ||||
| return $this->description; | return $this->description; | ||||
| } | } | ||||
| abstract protected function newControl(); | public function setIsLocked($is_locked) { | ||||
| $this->isLocked = $is_locked; | |||||
| return $this; | |||||
| } | |||||
| public function getIsLocked() { | |||||
| return $this->isLocked; | |||||
| } | |||||
| protected function newControl() { | |||||
| throw new PhutilMethodNotImplementedException(); | |||||
| } | |||||
| protected function renderControl() { | protected function renderControl() { | ||||
| $control = $this->newControl(); | $control = $this->newControl(); | ||||
| if ($control === null) { | if ($control === null) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| $control | $control | ||||
| ->setValue($this->getValueForControl()) | ->setValue($this->getValueForControl()) | ||||
| ->setName($this->getKey()); | ->setName($this->getKey()); | ||||
| if (!$control->getLabel()) { | if (!$control->getLabel()) { | ||||
| $control->setLabel($this->getLabel()); | $control->setLabel($this->getLabel()); | ||||
| } | } | ||||
| if ($this->getIsLocked()) { | |||||
| $control->setDisabled(true); | |||||
| } | |||||
| return $control; | return $control; | ||||
| } | } | ||||
| public function appendToForm(AphrontFormView $form) { | public function appendToForm(AphrontFormView $form) { | ||||
| $control = $this->renderControl(); | $control = $this->renderControl(); | ||||
| if ($control !== null) { | if ($control !== null) { | ||||
| $form->appendControl($control); | $form->appendControl($control); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | public function readValueFromRequest(AphrontRequest $request) { | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function readValueFromObject($object) { | public function readValueFromObject($object) { | ||||
| $this->value = $this->getValueFromObject($object); | $this->value = $this->getValueFromObject($object); | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function readDefaultValueFromConfiguration($value) { | |||||
| $this->value = $this->getDefaultValueFromConfiguration($value); | |||||
| return $this; | |||||
| } | |||||
| protected function getDefaultValueFromConfiguration($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(); | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 117 Lines • Show Last 20 Lines | |||||