Differential D14669 Diff 35492 src/applications/transactions/editfield/PhabricatorTokenizerEditField.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editfield/PhabricatorTokenizerEditField.php
| <?php | <?php | ||||
| abstract class PhabricatorTokenizerEditField | abstract class PhabricatorTokenizerEditField | ||||
| extends PhabricatorPHIDListEditField { | extends PhabricatorPHIDListEditField { | ||||
| private $commentActionDefaultValue; | |||||
| abstract protected function newDatasource(); | abstract protected function newDatasource(); | ||||
| public function setCommentActionDefaultValue(array $default) { | |||||
| $this->commentActionDefaultValue = $default; | |||||
| return $this; | |||||
| } | |||||
| public function getCommentActionDefaultValue() { | |||||
| return $this->commentActionDefaultValue; | |||||
| } | |||||
| protected function newControl() { | protected function newControl() { | ||||
| $control = id(new AphrontFormTokenizerControl()) | $control = id(new AphrontFormTokenizerControl()) | ||||
| ->setDatasource($this->newDatasource()); | ->setDatasource($this->newDatasource()); | ||||
| $initial_value = $this->getInitialValue(); | $initial_value = $this->getInitialValue(); | ||||
| if ($initial_value !== null) { | if ($initial_value !== null) { | ||||
| $control->setOriginalValue($initial_value); | $control->setOriginalValue($initial_value); | ||||
| } | } | ||||
| if ($this->getIsSingleValue()) { | if ($this->getIsSingleValue()) { | ||||
| $control->setLimit(1); | $control->setLimit(1); | ||||
| } | } | ||||
| return $control; | return $control; | ||||
| } | } | ||||
| protected function getInitialValueFromSubmit(AphrontRequest $request, $key) { | protected function getInitialValueFromSubmit(AphrontRequest $request, $key) { | ||||
| return $request->getArr($key.'.original'); | return $request->getArr($key.'.original'); | ||||
| } | } | ||||
| protected function newEditType() { | protected function newEditType() { | ||||
| $type = parent::newEditType(); | $type = parent::newEditType(); | ||||
| if ($this->getUseEdgeTransactions()) { | |||||
| $datasource = $this->newDatasource() | $datasource = $this->newDatasource() | ||||
| ->setViewer($this->getViewer()); | ->setViewer($this->getViewer()); | ||||
| $type->setDatasource($datasource); | $type->setDatasource($datasource); | ||||
| } | |||||
| return $type; | return $type; | ||||
| } | } | ||||
| public function getCommentEditTypes() { | public function getCommentEditTypes() { | ||||
| if (!$this->getUseEdgeTransactions()) { | $label = $this->getCommentActionLabel(); | ||||
| return parent::getCommentEditTypes(); | if ($label === null) { | ||||
| return array(); | |||||
| } | } | ||||
| $transaction_type = $this->getTransactionType(); | $transaction_type = $this->getTransactionType(); | ||||
| if ($transaction_type === null) { | if ($transaction_type === null) { | ||||
| return array(); | return array(); | ||||
| } | } | ||||
| $label = $this->getCommentActionLabel(); | if ($this->getUseEdgeTransactions()) { | ||||
| if ($label === null) { | |||||
| return array(); | |||||
| } | |||||
| $type_key = $this->getEditTypeKey(); | $type_key = $this->getEditTypeKey(); | ||||
| $base = $this->getEditType(); | $base = $this->getEditType(); | ||||
| $add = id(clone $base) | $add = id(clone $base) | ||||
| ->setEditType($type_key.'.add') | ->setEditType($type_key.'.add') | ||||
| ->setEdgeOperation('+') | ->setEdgeOperation('+') | ||||
| ->setLabel($label); | ->setLabel($label); | ||||
| return array($add); | return array($add); | ||||
| } | } | ||||
| $edit = $this->getEditType() | |||||
| ->setLabel($label); | |||||
| $default = $this->getCommentActionDefaultValue(); | |||||
| if ($default) { | |||||
| $edit->setDefaultValue($default); | |||||
| } | |||||
| return array($edit); | |||||
| } | |||||
| } | } | ||||