mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUG: Allow using instances for search filters.
Previously search filters could only be specified as strings, this allows instances to be used so more complex filter configuration can be used.
This commit is contained in:
parent
3ae8b0b665
commit
c058f97edd
@ -3161,14 +3161,23 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
*/
|
||||
public function defaultSearchFilters() {
|
||||
$filters = array();
|
||||
|
||||
foreach($this->searchableFields() as $name => $spec) {
|
||||
$filterClass = $spec['filter'];
|
||||
// if $filterClass is not set a name of any subclass of SearchFilter than assing 'PartiailMatchFilter' to it
|
||||
if (!is_subclass_of($filterClass, 'SearchFilter')) {
|
||||
$filterClass = 'PartialMatchFilter';
|
||||
|
||||
if($spec['filter'] instanceof SearchFilter) {
|
||||
$filters[$name] = $spec['filter'];
|
||||
} else {
|
||||
$class = $spec['filter'];
|
||||
|
||||
if(!is_subclass_of($spec['filter'], 'SearchFilter')) {
|
||||
$class = 'PartialMatchFilter';
|
||||
}
|
||||
|
||||
$filters[$name] = new $class($name);
|
||||
}
|
||||
$filters[$name] = new $filterClass($name);
|
||||
}
|
||||
|
||||
return $filters;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user