3 final class PhabricatorStandardCustomFieldInt
4 extends PhabricatorStandardCustomField
{
6 public function getFieldType() {
10 public function buildFieldIndexes() {
13 $value = $this->getFieldValue();
15 $indexes[] = $this->newNumericIndex((int)$value);
21 public function buildOrderIndex() {
22 return $this->newNumericIndex(0);
25 public function getValueForStorage() {
26 $value = $this->getFieldValue();
27 if ($value !== null && strlen($value)) {
34 public function setValueFromStorage($value) {
40 return $this->setFieldValue($value);
43 public function readApplicationSearchValueFromRequest(
44 PhabricatorApplicationSearchEngine
$engine,
45 AphrontRequest
$request) {
47 return $request->getStr($this->getFieldKey());
50 public function applyApplicationSearchConstraintToQuery(
51 PhabricatorApplicationSearchEngine
$engine,
52 PhabricatorCursorPagedPolicyAwareQuery
$query,
56 $query->withApplicationSearchContainsConstraint(
57 $this->newNumericIndex(null),
62 public function appendToApplicationSearchForm(
63 PhabricatorApplicationSearchEngine
$engine,
64 AphrontFormView
$form,
68 id(new AphrontFormTextControl())
69 ->setLabel($this->getFieldName())
70 ->setName($this->getFieldKey())
74 public function validateApplicationTransactions(
75 PhabricatorApplicationTransactionEditor
$editor,
79 $errors = parent
::validateApplicationTransactions(
84 foreach ($xactions as $xaction) {
85 $value = $xaction->getNewValue();
87 if (!preg_match('/^-?\d+/', $value)) {
88 $errors[] = new PhabricatorApplicationTransactionValidationError(
91 pht('%s must be an integer.', $this->getFieldName()),
93 $this->setFieldError(pht('Invalid'));
101 public function getApplicationTransactionHasEffect(
102 PhabricatorApplicationTransaction
$xaction) {
104 $old = $xaction->getOldValue();
105 $new = $xaction->getNewValue();
106 if (!strlen($old) && strlen($new)) {
108 } else if (strlen($old) && !strlen($new)) {
111 return ((int)$old !== (int)$new);
115 protected function getHTTPParameterType() {
116 return new AphrontIntHTTPParameterType();
119 protected function newConduitSearchParameterType() {
120 return new ConduitIntParameterType();
123 protected function newConduitEditParameterType() {
124 return new ConduitIntParameterType();
127 protected function newExportFieldType() {
128 return new PhabricatorIntExportField();