Skip to content

Commit d680b1f

Browse files
committed
Fix automatic content list not updating if multiple routes are used as
criteria
1 parent 7308f43 commit d680b1f

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/SWP/Bundle/CoreBundle/Matcher/ArticleCriteriaMatcher.php

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,29 @@ public function match(ArticleInterface $article, Criteria $criteria)
2828
}
2929

3030
if ($criteria->has('route')) {
31-
foreach ($criteria->get('route') as $value) {
32-
if (null !== $article->getRoute() && (int) $value !== $article->getRoute()->getId()) {
33-
return false;
31+
$routeFilter = $criteria->get('route');
32+
$articleRoute = $article->getRoute();
33+
34+
if (null === $articleRoute) {
35+
return false;
36+
}
37+
38+
$articleRouteId = $articleRoute->getId();
39+
40+
// Normalize route filter to an array of ids
41+
$routeIds = [];
42+
$values = is_array($routeFilter) ? $routeFilter : [$routeFilter];
43+
foreach ($values as $value) {
44+
if (is_object($value) && method_exists($value, 'getId')) {
45+
$routeIds[] = (int) $value->getId();
46+
} else {
47+
$routeIds[] = (int) $value;
3448
}
3549
}
50+
51+
if (!in_array((int) $articleRouteId, $routeIds, true)) {
52+
return false;
53+
}
3654
}
3755

3856
if ($criteria->has('author') && is_array($criteria->get('author'))) {

0 commit comments

Comments
 (0)