Differential D14653 Diff 35450 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 $commentActionLabel; | |||||
abstract protected function newDatasource(); | abstract protected function newDatasource(); | ||||
public function setCommentActionLabel($label) { | |||||
$this->commentActionLabel = $label; | |||||
return $this; | |||||
} | |||||
public function getCommentActionLabel() { | |||||
return $this->commentActionLabel; | |||||
} | |||||
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); | ||||
} | } | ||||
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() { | |||||
$type = parent::newEditType(); | |||||
if ($this->getUseEdgeTransactions()) { | |||||
$datasource = $this->newDatasource() | |||||
->setViewer($this->getViewer()); | |||||
$type->setDatasource($datasource); | |||||
} | |||||
return $type; | |||||
} | |||||
public function getCommentEditTypes() { | |||||
if (!$this->getUseEdgeTransactions()) { | |||||
return parent::getCommentEditTypes(); | |||||
} | |||||
$transaction_type = $this->getTransactionType(); | |||||
if ($transaction_type === null) { | |||||
return array(); | |||||
} | |||||
$label = $this->getCommentActionLabel(); | |||||
if ($label === null) { | |||||
return array(); | |||||
} | |||||
$type_key = $this->getEditTypeKey(); | |||||
$base = $this->getEditType(); | |||||
$add = id(clone $base) | |||||
->setEditType($type_key.'.add') | |||||
->setEdgeOperation('+') | |||||
->setLabel($label); | |||||
return array($add); | |||||
} | |||||
} | } |