Skip to content

Commit 1663f38

Browse files
committed
Improve filtering
Make filter work with multiple keys and wildcard search, eg. user/* or ip 10.0.*
1 parent 12997a3 commit 1663f38

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/DebugBar/Storage/FileStorage.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function find(array $filters = array(), $max = 20, $offset = 0)
7777
$data = $this->get($file['id']);
7878
$meta = $data['__meta'];
7979
unset($data);
80-
if (array_keys(array_intersect($meta, $filters)) == array_keys($filters)) {
80+
if ($this->filter($meta, $filters)) {
8181
$results[] = $meta;
8282
}
8383
if(count($results) >= ($max + $offset)){
@@ -87,6 +87,15 @@ public function find(array $filters = array(), $max = 20, $offset = 0)
8787

8888
return array_slice($results, $offset, $max);
8989
}
90+
91+
protected function filter($meta, $filters){
92+
foreach($filters as $key => $value){
93+
if(fnmatch ($value, $meta[$key]) === false){
94+
return false;
95+
}
96+
}
97+
return true;
98+
}
9099

91100
/**
92101
* {@inheritDoc}

0 commit comments

Comments
 (0)