Skip to content

Commit

Permalink
Modified filter function.
Browse files Browse the repository at this point in the history
  • Loading branch information
nilov authored Apr 28, 2017
1 parent 796f7b3 commit eedfdd2
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/Extension/CmsTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,31 @@ public function listFilter(array $list, array $filters)
return array_filter($list, function ($item) use ($filters) {
foreach ($filters as $filter) {
foreach ($filter as $filterName => $filterValue) {
if (!isset($item[$filterName]) || $item[$filterName] != $filterValue) {
return false;
if (strpos($filterName, '.')) {
$filterNameParts = explode('.', $filterName);

$itemValue = $item;
foreach ($filterNameParts as $filterNamePart) {
if (!isset($itemValue[$filterNamePart])) {
return false;
}

$itemValue = $itemValue[$filterNamePart];
}

} else {
if (!isset($item[$filterName])) {
return false;
}

$itemValue = $item[$filterName];
}

return true;
return $itemValue == $filterValue;
}
}

return false;
});
}
}

0 comments on commit eedfdd2

Please sign in to comment.