3 final class PhabricatorSearchCheckboxesField
4 extends PhabricatorSearchField
{
7 private $deprecatedOptions = array();
9 public function setOptions(array $options) {
10 $this->options
= $options;
14 public function getOptions() {
15 return $this->options
;
18 public function setDeprecatedOptions(array $deprecated_options) {
19 $this->deprecatedOptions
= $deprecated_options;
23 public function getDeprecatedOptions() {
24 return $this->deprecatedOptions
;
27 protected function getDefaultValue() {
31 protected function didReadValueFromSavedQuery($value) {
32 if (!is_array($value)) {
36 return $this->getCanonicalValue($value);
39 protected function getValueFromRequest(AphrontRequest
$request, $key) {
40 $value = $this->getListFromRequest($request, $key);
41 return $this->getCanonicalValue($value);
44 protected function newControl() {
45 $value = array_fuse($this->getValue());
47 $control = new AphrontFormCheckboxControl();
48 foreach ($this->getOptions() as $key => $option) {
49 $control->addCheckbox(
59 protected function newConduitParameterType() {
60 return new ConduitStringListParameterType();
63 public function newConduitConstants() {
66 foreach ($this->getOptions() as $key => $option) {
67 $list[] = id(new ConduitConstantDescription())
72 foreach ($this->getDeprecatedOptions() as $key => $value) {
73 $list[] = id(new ConduitConstantDescription())
75 ->setIsDeprecated(true)
76 ->setValue(pht('Deprecated alias for "%s".', $value));
82 private function getCanonicalValue(array $values) {
83 // Always map the current normal options to themselves.
84 $normal_options = array_fuse(array_keys($this->getOptions()));
86 // Map deprecated values to their new values.
87 $deprecated_options = $this->getDeprecatedOptions();
89 $map = $normal_options +
$deprecated_options;
90 foreach ($values as $key => $value) {
91 $values[$key] = idx($map, $value, $value);