Differential D14789 Diff 35772 src/applications/transactions/editfield/PhabricatorSelectEditField.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editfield/PhabricatorSelectEditField.php
<?php | <?php | ||||
final class PhabricatorSelectEditField | final class PhabricatorSelectEditField | ||||
extends PhabricatorEditField { | extends PhabricatorEditField { | ||||
private $options; | private $options; | ||||
private $commentActionDefaultValue; | |||||
public function setOptions(array $options) { | public function setOptions(array $options) { | ||||
$this->options = $options; | $this->options = $options; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getOptions() { | public function getOptions() { | ||||
if ($this->options === null) { | if ($this->options === null) { | ||||
throw new PhutilInvalidStateException('setOptions'); | throw new PhutilInvalidStateException('setOptions'); | ||||
} | } | ||||
return $this->options; | return $this->options; | ||||
} | } | ||||
public function setCommentActionDefaultValue($default) { | |||||
$this->commentActionDefaultValue = $default; | |||||
return $this; | |||||
} | |||||
public function getCommentActionDefaultValue() { | |||||
return $this->commentActionDefaultValue; | |||||
} | |||||
protected function newControl() { | protected function newControl() { | ||||
return id(new AphrontFormSelectControl()) | return id(new AphrontFormSelectControl()) | ||||
->setOptions($this->getOptions()); | ->setOptions($this->getOptions()); | ||||
} | } | ||||
protected function newHTTPParameterType() { | protected function newHTTPParameterType() { | ||||
return new AphrontSelectHTTPParameterType(); | return new AphrontSelectHTTPParameterType(); | ||||
} | } | ||||
public function getCommentEditTypes() { | protected function newCommentAction() { | ||||
$label = $this->getCommentActionLabel(); | return id(new PhabricatorEditEngineSelectCommentAction()) | ||||
if ($label === null) { | ->setOptions($this->getOptions()); | ||||
return array(); | |||||
} | |||||
$default_value = $this->getCommentActionDefaultValue(); | |||||
if ($default_value === null) { | |||||
$default_value = $this->getValue(); | |||||
} | |||||
$edit = $this->getEditType() | |||||
->setLabel($label) | |||||
->setPHUIXControlType('select') | |||||
->setPHUIXControlSpecification( | |||||
array( | |||||
'options' => $this->getOptions(), | |||||
'order' => array_keys($this->getOptions()), | |||||
'value' => $default_value, | |||||
)); | |||||
return array($edit); | |||||
} | } | ||||
} | } |