Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/infrastructure/customfield/datasource/PhabricatorCustomFieldApplicationSearchNoneFunctionDatasource.php
12242 views
1
<?php
2
3
final class PhabricatorCustomFieldApplicationSearchNoneFunctionDatasource
4
extends PhabricatorTypeaheadDatasource {
5
6
public function getBrowseTitle() {
7
return pht('Browse No Value');
8
}
9
10
public function getPlaceholderText() {
11
return pht('Type "none()"...');
12
}
13
14
public function getDatasourceApplicationClass() {
15
return null;
16
}
17
18
public function getDatasourceFunctions() {
19
return array(
20
'none' => array(
21
'name' => pht('No Value'),
22
'summary' => pht('Find results with no value.'),
23
'description' => pht(
24
"This function includes results which have no value. Use a query ".
25
"like this to find results with no value:\n\n%s\n\n".
26
'If you combine this function with other constraints, results '.
27
'which have no value or the specified values will be returned.',
28
'> any()'),
29
),
30
);
31
}
32
33
public function loadResults() {
34
$results = array(
35
$this->newNoneFunction(),
36
);
37
return $this->filterResultsAgainstTokens($results);
38
}
39
40
protected function evaluateFunction($function, array $argv_list) {
41
$results = array();
42
43
foreach ($argv_list as $argv) {
44
$results[] = new PhabricatorQueryConstraint(
45
PhabricatorQueryConstraint::OPERATOR_NULL,
46
null);
47
}
48
49
return $results;
50
}
51
52
public function renderFunctionTokens($function, array $argv_list) {
53
$results = array();
54
foreach ($argv_list as $argv) {
55
$results[] = PhabricatorTypeaheadTokenView::newFromTypeaheadResult(
56
$this->newNoneFunction());
57
}
58
return $results;
59
}
60
61
private function newNoneFunction() {
62
$name = pht('No Value');
63
return $this->newFunctionResult()
64
->setName($name.' none')
65
->setDisplayName($name)
66
->setIcon('fa-ban')
67
->setPHID('none()')
68
->setUnique(true)
69
->addAttribute(pht('Select results with no value.'));
70
}
71
72
}
73
74