Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/dashboard/xaction/panel/PhabricatorDashboardQueryPanelLimitTransaction.php
13441 views
1
<?php
2
3
final class PhabricatorDashboardQueryPanelLimitTransaction
4
extends PhabricatorDashboardPanelPropertyTransaction {
5
6
const TRANSACTIONTYPE = 'search.limit';
7
8
protected function getPropertyKey() {
9
return 'limit';
10
}
11
12
public function generateNewValue($object, $value) {
13
if (!$value) {
14
return null;
15
}
16
17
return $value;
18
}
19
20
public function validateTransactions($object, array $xactions) {
21
$errors = array();
22
23
$old_value = $object->getProperty($this->getPropertyKey());
24
foreach ($xactions as $xaction) {
25
$new_value = $xaction->getNewValue();
26
27
if ($new_value === $old_value) {
28
continue;
29
}
30
31
if ($new_value < 0) {
32
$errors[] = $this->newInvalidError(
33
pht(
34
'Query result limit must be empty, or at least 1.'),
35
$xaction);
36
continue;
37
}
38
}
39
40
return $errors;
41
}
42
43
}
44
45