2015-07-16 14:12:00 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class HeraldSelectFieldValue
|
|
|
|
extends HeraldFieldValue {
|
|
|
|
|
|
|
|
private $key;
|
|
|
|
private $options;
|
|
|
|
private $default;
|
|
|
|
|
|
|
|
public function setKey($key) {
|
|
|
|
$this->key = $key;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getKey() {
|
|
|
|
return $this->key;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setOptions(array $options) {
|
|
|
|
$this->options = $options;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getOptions() {
|
|
|
|
return $this->options;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setDefault($default) {
|
|
|
|
$this->default = $default;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDefault() {
|
|
|
|
return $this->default;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFieldValueKey() {
|
|
|
|
if ($this->getKey() === null) {
|
|
|
|
throw new PhutilInvalidStateException('setKey');
|
|
|
|
}
|
|
|
|
return 'select.'.$this->getKey();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getControlType() {
|
|
|
|
return self::CONTROL_SELECT;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getControlTemplate() {
|
|
|
|
if ($this->getOptions() === null) {
|
|
|
|
throw new PhutilInvalidStateException('setOptions');
|
|
|
|
}
|
|
|
|
|
|
|
|
return array(
|
|
|
|
'options' => $this->getOptions(),
|
|
|
|
'default' => $this->getDefault(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-07-16 14:12:44 -07:00
|
|
|
public function renderFieldValue($value) {
|
2015-07-16 14:12:23 -07:00
|
|
|
$options = $this->getOptions();
|
|
|
|
return idx($options, $value, $value);
|
|
|
|
}
|
|
|
|
|
2015-07-16 14:12:54 -07:00
|
|
|
public function renderEditorValue($value) {
|
|
|
|
return $value;
|
|
|
|
}
|
|
|
|
|
2015-07-16 14:12:00 -07:00
|
|
|
}
|