Skip to content

Commit f392314

Browse files
committed
fix for #701
1 parent a7f1fb7 commit f392314

File tree

2 files changed

+26
-36
lines changed

2 files changed

+26
-36
lines changed

api.php

+13-18
Original file line numberDiff line numberDiff line change
@@ -9937,27 +9937,22 @@ public function getStatus(): int
99379937

99389938
class FilterInfo
99399939
{
9940-
private function addConditionFromFilterPath(PathTree $conditions, array $path, ReflectedTable $table, array $params)
9941-
{
9942-
$key = 'filter' . implode('', $path);
9943-
if (isset($params[$key])) {
9944-
foreach ($params[$key] as $filter) {
9945-
$condition = Condition::fromString($table, $filter);
9946-
if (($condition instanceof NoCondition) == false) {
9947-
$conditions->put($path, $condition);
9948-
}
9949-
}
9950-
}
9951-
}
9952-
99539940
private function getConditionsAsPathTree(ReflectedTable $table, array $params): PathTree
99549941
{
99559942
$conditions = new PathTree();
9956-
$this->addConditionFromFilterPath($conditions, [], $table, $params);
9957-
for ($n = ord('0'); $n <= ord('9'); $n++) {
9958-
$this->addConditionFromFilterPath($conditions, [chr($n)], $table, $params);
9959-
for ($l = ord('a'); $l <= ord('f'); $l++) {
9960-
$this->addConditionFromFilterPath($conditions, [chr($n), chr($l)], $table, $params);
9943+
foreach ($params as $key => $filters) {
9944+
if (substr($key, 0, 6) == 'filter') {
9945+
$path = [];
9946+
$suffix = substr($key, 6);
9947+
if ($suffix) {
9948+
$path = str_split($suffix);
9949+
}
9950+
foreach ($filters as $filter) {
9951+
$condition = Condition::fromString($table, $filter);
9952+
if (($condition instanceof NoCondition) == false) {
9953+
$conditions->put($path, $condition);
9954+
}
9955+
}
99619956
}
99629957
}
99639958
return $conditions;

src/Tqdev/PhpCrudApi/Record/FilterInfo.php

+13-18
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,22 @@
1010

1111
class FilterInfo
1212
{
13-
private function addConditionFromFilterPath(PathTree $conditions, array $path, ReflectedTable $table, array $params)
14-
{
15-
$key = 'filter' . implode('', $path);
16-
if (isset($params[$key])) {
17-
foreach ($params[$key] as $filter) {
18-
$condition = Condition::fromString($table, $filter);
19-
if (($condition instanceof NoCondition) == false) {
20-
$conditions->put($path, $condition);
21-
}
22-
}
23-
}
24-
}
25-
2613
private function getConditionsAsPathTree(ReflectedTable $table, array $params): PathTree
2714
{
2815
$conditions = new PathTree();
29-
$this->addConditionFromFilterPath($conditions, [], $table, $params);
30-
for ($n = ord('0'); $n <= ord('9'); $n++) {
31-
$this->addConditionFromFilterPath($conditions, [chr($n)], $table, $params);
32-
for ($l = ord('a'); $l <= ord('f'); $l++) {
33-
$this->addConditionFromFilterPath($conditions, [chr($n), chr($l)], $table, $params);
16+
foreach ($params as $key => $filters) {
17+
if (substr($key, 0, 6) == 'filter') {
18+
$path = [];
19+
$suffix = substr($key, 6);
20+
if ($suffix) {
21+
$path = str_split($suffix);
22+
}
23+
foreach ($filters as $filter) {
24+
$condition = Condition::fromString($table, $filter);
25+
if (($condition instanceof NoCondition) == false) {
26+
$conditions->put($path, $condition);
27+
}
28+
}
3429
}
3530
}
3631
return $conditions;

0 commit comments

Comments
 (0)