1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-01-17 21:38:14 +01:00

Improve filtering

Make filter work with multiple keys and wildcard search, eg. user/* or ip 10.0.*
This commit is contained in:
Barry vd. Heuvel 2014-01-14 09:52:37 +01:00
parent 12997a339d
commit 1663f3808b

View File

@ -77,7 +77,7 @@ class FileStorage implements StorageInterface
$data = $this->get($file['id']); $data = $this->get($file['id']);
$meta = $data['__meta']; $meta = $data['__meta'];
unset($data); unset($data);
if (array_keys(array_intersect($meta, $filters)) == array_keys($filters)) { if ($this->filter($meta, $filters)) {
$results[] = $meta; $results[] = $meta;
} }
if(count($results) >= ($max + $offset)){ if(count($results) >= ($max + $offset)){
@ -88,6 +88,15 @@ class FileStorage implements StorageInterface
return array_slice($results, $offset, $max); return array_slice($results, $offset, $max);
} }
protected function filter($meta, $filters){
foreach($filters as $key => $value){
if(fnmatch ($value, $meta[$key]) === false){
return false;
}
}
return true;
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */