testing search function

This commit is contained in:
Viktor Pedersen 2021-09-08 16:05:43 +02:00
parent 55882611e7
commit fa30f4b0f7

@ -122,38 +122,43 @@ class Product extends Entity {
if(property_exists($this, $field)) {
if(match($values, $this->$field)) {
$matches[$field] = $this->$field;
} else {
if($matchAll) {
return array();
}
}
} else if(array_key_exists($field, $this->get_info())) {
if(match($values, $this->get_info()[$field])) {
$matches[$field] = $this->get_info()[$field];
} else {
if($matchAll) {
return array();
}
}
} else if($field == 'tag') {
foreach($this->get_tags() as $tag) {
if(match($values, $tag)) {
$matches['tags'] = $this->get_tags();
if(!array_key_exists('tags', $matches)) {
$matches['tags'] = array();
}
$matches['tags'][] = $tag;
break;
} else {
if($matchAll) {
return array();
}
}
}
} else if($field == 'status') {
if(match($values, $this->get_status())) {
$matches['status'] = $this->get_status();
} else {
if($matchAll) {
return array();
}
}
}
}
if($matchAll && array_diff_assoc($terms, $matches)) {
print('=== DEBUG $terms ===<br>');
var_dump($terms);
print('<br><br>');
print('=== DEBUG diff $terms and $matches ===<br>');
var_dump(array_diff_assoc($terms, $matches));
print('<br><br>');
print('=== DEBUG $matches ===<br>');
var_dump($matches);
print('<br><br>');
return array();
}
return $matches;
}