Differential D12224 Diff 29377 src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldUsers.php
Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldUsers.php
<?php | <?php | ||||
final class PhabricatorStandardCustomFieldUsers | final class PhabricatorStandardCustomFieldUsers | ||||
extends PhabricatorStandardCustomFieldPHIDs { | extends PhabricatorStandardCustomFieldPHIDs { | ||||
public function getFieldType() { | public function getFieldType() { | ||||
return 'users'; | return 'users'; | ||||
} | } | ||||
public function renderEditControl(array $handles) { | public function renderEditControl(array $handles) { | ||||
$value = $this->getFieldValue(); | $value = $this->getFieldValue(); | ||||
if ($value) { | |||||
$control_value = array_select_keys($handles, $value); | |||||
} else { | |||||
$control_value = array(); | |||||
} | |||||
$control = id(new AphrontFormTokenizerControl()) | $control = id(new AphrontFormTokenizerControl()) | ||||
->setUser($this->getViewer()) | |||||
->setLabel($this->getFieldName()) | ->setLabel($this->getFieldName()) | ||||
->setName($this->getFieldKey()) | ->setName($this->getFieldKey()) | ||||
->setDatasource(new PhabricatorPeopleDatasource()) | ->setDatasource(new PhabricatorPeopleDatasource()) | ||||
->setCaption($this->getCaption()) | ->setCaption($this->getCaption()) | ||||
->setValue($control_value); | ->setValue(nonempty($value, array())); | ||||
$limit = $this->getFieldConfigValue('limit'); | $limit = $this->getFieldConfigValue('limit'); | ||||
if ($limit) { | if ($limit) { | ||||
$control->setLimit($limit); | $control->setLimit($limit); | ||||
} | } | ||||
return $control; | return $control; | ||||
} | } | ||||
public function appendToApplicationSearchForm( | public function appendToApplicationSearchForm( | ||||
PhabricatorApplicationSearchEngine $engine, | PhabricatorApplicationSearchEngine $engine, | ||||
AphrontFormView $form, | AphrontFormView $form, | ||||
$value, | $value, | ||||
array $handles) { | array $handles) { | ||||
$control = id(new AphrontFormTokenizerControl()) | $control = id(new AphrontFormTokenizerControl()) | ||||
->setLabel($this->getFieldName()) | ->setLabel($this->getFieldName()) | ||||
->setName($this->getFieldKey()) | ->setName($this->getFieldKey()) | ||||
->setDatasource(new PhabricatorPeopleDatasource()) | ->setDatasource(new PhabricatorPeopleDatasource()) | ||||
->setValue($handles); | ->setValue(nonempty($value, array())); | ||||
$form->appendChild($control); | $form->appendControl($control); | ||||
} | } | ||||
public function getHeraldFieldValueType($condition) { | public function getHeraldFieldValueType($condition) { | ||||
return HeraldAdapter::VALUE_USER; | return HeraldAdapter::VALUE_USER; | ||||
} | } | ||||
} | } |