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; | private $isLocked; | ||||
| private $isPreview; | |||||
| private $isReorderable = true; | |||||
| 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 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | public function setIsLocked($is_locked) { | ||||
| $this->isLocked = $is_locked; | $this->isLocked = $is_locked; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getIsLocked() { | public function getIsLocked() { | ||||
| return $this->isLocked; | return $this->isLocked; | ||||
| } | } | ||||
| public function setIsPreview($preview) { | |||||
| $this->isPreview = $preview; | |||||
| return $this; | |||||
| } | |||||
| public function getIsPreview() { | |||||
| return $this->isPreview; | |||||
| } | |||||
| public function setIsReorderable($is_reorderable) { | |||||
| $this->isReorderable = $is_reorderable; | |||||
| return $this; | |||||
| } | |||||
| public function getIsReorderable() { | |||||
| return $this->isReorderable; | |||||
| } | |||||
| protected function newControl() { | protected function newControl() { | ||||
| throw new PhutilMethodNotImplementedException(); | 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()) { | if ($this->getIsLocked() || $this->getIsPreview()) { | ||||
| $control->setDisabled(true); | $control->setDisabled(true); | ||||
| } | } | ||||
| return $control; | return $control; | ||||
| } | } | ||||
| public function appendToForm(AphrontFormView $form) { | public function appendToForm(AphrontFormView $form) { | ||||
| $control = $this->renderControl(); | $control = $this->renderControl(); | ||||
| Show All 36 Lines | public function setMetadataValue($key, $value) { | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| protected function getValueForTransaction() { | protected function getValueForTransaction() { | ||||
| return $this->getValue(); | return $this->getValue(); | ||||
| } | } | ||||
| public function getTransactionType() { | public function getTransactionType() { | ||||
| if (!$this->transactionType) { | |||||
| throw new PhutilInvalidStateException('setTransactionType'); | |||||
| } | |||||
| return $this->transactionType; | return $this->transactionType; | ||||
| } | } | ||||
| public function setTransactionType($type) { | public function setTransactionType($type) { | ||||
| $this->transactionType = $type; | $this->transactionType = $type; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | public function getEditTypeKey() { | ||||
| if ($this->editTypeKey === null) { | if ($this->editTypeKey === null) { | ||||
| return $this->getKey(); | return $this->getKey(); | ||||
| } | } | ||||
| return $this->editTypeKey; | return $this->editTypeKey; | ||||
| } | } | ||||
| public function getEditTransactionTypes() { | public function getEditTransactionTypes() { | ||||
| $transaction_type = $this->getTransactionType(); | $transaction_type = $this->getTransactionType(); | ||||
| if ($transaction_type === null) { | |||||
| return array(); | |||||
| } | |||||
| $type_key = $this->getEditTypeKey(); | $type_key = $this->getEditTypeKey(); | ||||
| // TODO: This is a pretty big pile of hard-coded hacks for now. | // TODO: This is a pretty big pile of hard-coded hacks for now. | ||||
| $edge_types = array( | $edge_types = array( | ||||
| PhabricatorTransactions::TYPE_EDGE => array( | PhabricatorTransactions::TYPE_EDGE => array( | ||||
| '+' => pht('Add projects.'), | '+' => pht('Add projects.'), | ||||
| '-' => pht('Remove projects.'), | '-' => pht('Remove projects.'), | ||||
| ▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines | |||||