3 final class PhabricatorStandardCustomFieldSelect
4 extends PhabricatorStandardCustomField
{
6 public function getFieldType() {
10 public function buildFieldIndexes() {
13 $value = $this->getFieldValue();
15 $indexes[] = $this->newStringIndex($value);
21 public function readApplicationSearchValueFromRequest(
22 PhabricatorApplicationSearchEngine
$engine,
23 AphrontRequest
$request) {
24 return $request->getArr($this->getFieldKey());
27 public function applyApplicationSearchConstraintToQuery(
28 PhabricatorApplicationSearchEngine
$engine,
29 PhabricatorCursorPagedPolicyAwareQuery
$query,
32 $query->withApplicationSearchContainsConstraint(
33 $this->newStringIndex(null),
38 public function appendToApplicationSearchForm(
39 PhabricatorApplicationSearchEngine
$engine,
40 AphrontFormView
$form,
43 if (!is_array($value)) {
46 $value = array_fuse($value);
48 $control = id(new AphrontFormCheckboxControl())
49 ->setLabel($this->getFieldName());
51 foreach ($this->getOptions() as $name => $option) {
52 $control->addCheckbox(
53 $this->getFieldKey().'[]',
56 isset($value[$name]));
59 $form->appendChild($control);
62 public function getOptions() {
63 return $this->getFieldConfigValue('options', array());
66 public function renderEditControl(array $handles) {
67 return id(new AphrontFormSelectControl())
68 ->setLabel($this->getFieldName())
69 ->setCaption($this->getCaption())
70 ->setName($this->getFieldKey())
71 ->setValue($this->getFieldValue())
72 ->setOptions($this->getOptions());
75 public function renderPropertyViewValue(array $handles) {
76 if (!strlen($this->getFieldValue())) {
79 return idx($this->getOptions(), $this->getFieldValue());
82 public function getApplicationTransactionTitle(
83 PhabricatorApplicationTransaction
$xaction) {
84 $author_phid = $xaction->getAuthorPHID();
85 $old = $xaction->getOldValue();
86 $new = $xaction->getNewValue();
88 $old = idx($this->getOptions(), $old, $old);
89 $new = idx($this->getOptions(), $new, $new);
94 $xaction->renderHandleLink($author_phid),
95 $this->getFieldName(),
100 $xaction->renderHandleLink($author_phid),
101 $this->getFieldName());
104 '%s changed %s from %s to %s.',
105 $xaction->renderHandleLink($author_phid),
106 $this->getFieldName(),
112 public function shouldAppearInHerald() {
116 public function getHeraldFieldConditions() {
118 HeraldAdapter
::CONDITION_IS_ANY
,
119 HeraldAdapter
::CONDITION_IS_NOT_ANY
,
123 public function getHeraldFieldValueType($condition) {
125 'object' => get_class($this->getObject()),
126 'role' => PhabricatorCustomField
::ROLE_HERALD
,
127 'key' => $this->getFieldKey(),
130 $datasource = id(new PhabricatorStandardSelectCustomFieldDatasource())
131 ->setParameters($parameters);
133 return id(new HeraldTokenizerFieldValue())
134 ->setKey('custom.'.$this->getFieldKey())
135 ->setDatasource($datasource)
136 ->setValueMap($this->getOptions());
139 protected function getHTTPParameterType() {
140 return new AphrontSelectHTTPParameterType();
143 protected function newConduitSearchParameterType() {
144 return new ConduitStringListParameterType();
147 protected function newConduitEditParameterType() {
148 return new ConduitStringParameterType();
151 protected function newBulkParameterType() {
152 return id(new BulkSelectParameterType())
153 ->setOptions($this->getOptions());
156 protected function newExportFieldType() {
157 return id(new PhabricatorOptionExportField())
158 ->setOptions($this->getOptions());