mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-28 01:32:42 +01:00
2b538bfb25
Summary: Currently, `ManiphestAuxiliaryFieldDefaultSpecification` uses about a dozen giant `switch` statements to implement stadard field types (int, string, date, bool, select, user, remarkup, etc). This is: - pretty gross; - not extensible; and - doesn't really let us share that much code. I got about halfway through porting a similar implementation into StandardField but I wasn't thrilled with it. Subclass StandardField instead to implement custom field types. Test Plan: Added an "int" custom field, verified it had integer semantics and indexed into the integer index. Reviewers: btrahan Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D7005
53 lines
1.2 KiB
PHP
53 lines
1.2 KiB
PHP
<?php
|
|
|
|
final class PhabricatorStandardCustomFieldText
|
|
extends PhabricatorStandardCustomField {
|
|
|
|
public function getFieldType() {
|
|
return 'text';
|
|
}
|
|
|
|
public function buildFieldIndexes() {
|
|
$indexes = array();
|
|
|
|
$value = $this->getFieldValue();
|
|
if (strlen($value)) {
|
|
$indexes[] = $this->newStringIndex($value);
|
|
}
|
|
|
|
return $indexes;
|
|
}
|
|
|
|
public function readApplicationSearchValueFromRequest(
|
|
PhabricatorApplicationSearchEngine $engine,
|
|
AphrontRequest $request) {
|
|
|
|
return $request->getStr($this->getFieldKey());
|
|
}
|
|
|
|
public function applyApplicationSearchConstraintToQuery(
|
|
PhabricatorApplicationSearchEngine $engine,
|
|
PhabricatorCursorPagedPolicyAwareQuery $query,
|
|
$value) {
|
|
|
|
if (strlen($value)) {
|
|
$query->withApplicationSearchContainsConstraint(
|
|
$this->newStringIndex(null),
|
|
$value);
|
|
}
|
|
}
|
|
|
|
public function appendToApplicationSearchForm(
|
|
PhabricatorApplicationSearchEngine $engine,
|
|
AphrontFormView $form,
|
|
$value,
|
|
array $handles) {
|
|
|
|
$form->appendChild(
|
|
id(new AphrontFormTextControl())
|
|
->setLabel($this->getFieldName())
|
|
->setName($this->getFieldKey())
|
|
->setValue($value));
|
|
}
|
|
|
|
}
|