3 abstract class PhabricatorStandardCustomFieldTokenizer
4 extends PhabricatorStandardCustomFieldPHIDs
{
6 abstract public function getDatasource();
8 public function renderEditControl(array $handles) {
9 $value = $this->getFieldValue();
11 $control = id(new AphrontFormTokenizerControl())
12 ->setUser($this->getViewer())
13 ->setLabel($this->getFieldName())
14 ->setName($this->getFieldKey())
15 ->setDatasource($this->getDatasource())
16 ->setCaption($this->getCaption())
17 ->setError($this->getFieldError())
18 ->setValue(nonempty($value, array()));
20 $limit = $this->getFieldConfigValue('limit');
22 $control->setLimit($limit);
28 public function appendToApplicationSearchForm(
29 PhabricatorApplicationSearchEngine
$engine,
30 AphrontFormView
$form,
33 $control = id(new AphrontFormTokenizerControl())
34 ->setLabel($this->getFieldName())
35 ->setName($this->getFieldKey())
36 ->setDatasource($this->newApplicationSearchDatasource())
37 ->setValue(nonempty($value, array()));
39 $form->appendControl($control);
42 public function applyApplicationSearchConstraintToQuery(
43 PhabricatorApplicationSearchEngine
$engine,
44 PhabricatorCursorPagedPolicyAwareQuery
$query,
48 $datasource = $this->newApplicationSearchDatasource()
49 ->setViewer($this->getViewer());
50 $value = $datasource->evaluateTokens($value);
52 $query->withApplicationSearchContainsConstraint(
53 $this->newStringIndex(null),
58 public function getHeraldFieldValueType($condition) {
59 return id(new HeraldTokenizerFieldValue())
60 ->setKey('custom.'.$this->getFieldKey())
61 ->setDatasource($this->getDatasource());
64 public function getHeraldFieldStandardType() {
65 return HeraldField
::STANDARD_PHID_LIST
;
68 public function getHeraldDatasource() {
69 return $this->getDatasource();
72 protected function getHTTPParameterType() {
73 return new AphrontPHIDListHTTPParameterType();
76 protected function newConduitSearchParameterType() {
77 return new ConduitPHIDListParameterType();
80 protected function newConduitEditParameterType() {
81 return new ConduitPHIDListParameterType();
84 protected function newBulkParameterType() {
85 $datasource = $this->getDatasource();
87 $limit = $this->getFieldConfigValue('limit');
89 $datasource->setLimit($limit);
92 return id(new BulkTokenizerParameterType())
93 ->setDatasource($datasource);
96 public function shouldAppearInHeraldActions() {
100 public function getHeraldActionName() {
101 return pht('Set "%s" to', $this->getFieldName());
104 public function getHeraldActionDescription($value) {
105 $list = $this->renderHeraldHandleList($value);
106 return pht('Set "%s" to: %s.', $this->getFieldName(), $list);
109 public function getHeraldActionEffectDescription($value) {
110 return $this->renderHeraldHandleList($value);
113 public function getHeraldActionStandardType() {
114 return HeraldAction
::STANDARD_PHID_LIST
;
117 public function getHeraldActionDatasource() {
118 $datasource = $this->getDatasource();
120 $limit = $this->getFieldConfigValue('limit');
122 $datasource->setLimit($limit);
128 private function renderHeraldHandleList($value) {
129 if (!is_array($value)) {
130 return pht('(Invalid List)');
132 return $this->getViewer()
133 ->renderHandleList($value)
139 protected function newApplicationSearchDatasource() {
140 $datasource = $this->getDatasource();
142 return id(new PhabricatorCustomFieldApplicationSearchDatasource())
143 ->setDatasource($datasource);
146 protected function newCommentAction() {
147 $viewer = $this->getViewer();
149 $datasource = $this->getDatasource()
150 ->setViewer($viewer);
152 $action = id(new PhabricatorEditEngineTokenizerCommentAction())
153 ->setDatasource($datasource);
155 $limit = $this->getFieldConfigValue('limit');
157 $action->setLimit($limit);
160 $value = $this->getFieldValue();
161 if ($value !== null) {
162 $action->setInitialValue($value);