Skip to content

Commit 13f9c6f

Browse files
committed
Fix on same op (#144)
Change-Id: I9bfc17c3899eacac24ec7de487705cfeeb91a81a
1 parent ea0ca13 commit 13f9c6f

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

app/Http/Utils/Filters/DoctrineInstanceOfFilterMapping.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,29 @@ private function translateClassName($value)
4747
return $value;
4848
}
4949

50+
private function buildWhere(QueryBuilder $query, FilterElement $filter):string{
51+
$value = $filter->getValue();
52+
53+
if (is_array($value)) {
54+
$where_components = [];
55+
56+
foreach ($value as $val) {
57+
$where_components[] = str_replace(":class_name", $this->translateClassName($val), $this->where);
58+
}
59+
60+
return implode(sprintf(" %s ", $filter->getSameFieldOp()), $where_components);
61+
}
62+
return str_replace(":class_name", $this->translateClassName($filter->getValue()), $this->where);
63+
}
64+
5065
/**
5166
* @param QueryBuilder $query
5267
* @param FilterElement $filter
5368
* @return QueryBuilder
5469
*/
5570
public function apply(QueryBuilder $query, FilterElement $filter): QueryBuilder
5671
{
57-
$where = str_replace(":class_name", $this->translateClassName($filter->getValue()), $this->where);
58-
return $query->andWhere($where);
72+
return $query->andWhere($this->buildWhere($query, $filter));
5973
}
6074

6175
/**
@@ -65,8 +79,7 @@ public function apply(QueryBuilder $query, FilterElement $filter): QueryBuilder
6579
*/
6680
public function applyOr(QueryBuilder $query, FilterElement $filter): string
6781
{
68-
$where = str_replace(":class_name", $this->translateClassName($filter->getValue()), $this->where);
69-
return $where;
82+
return $this->buildWhere($query, $filter);
7083
}
7184

7285
}

0 commit comments

Comments
 (0)