1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-30 16:38:21 +01:00
phorge-phorge/src/applications/herald/value/HeraldSelectFieldValue.php
epriestley 97ccd93670 Support "Select" custom fields in Herald rules
Summary: Fixes T5016. Ref T655. Ref T8434. Ref T8726. For "select" custom fields, permit construction of Herald rules.

Test Plan: {F602997}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T655, T5016, T8434, T8726

Differential Revision: https://secure.phabricator.com/D13618
2015-07-16 14:12:54 -07:00

68 lines
1.3 KiB
PHP

<?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(),
);
}
public function renderFieldValue($value) {
$options = $this->getOptions();
return idx($options, $value, $value);
}
public function renderEditorValue($value) {
return $value;
}
}