Class SearchContext
Manages searching of properties on one or more DataObject types,
based on a given set of input parameters. SearchContext is intentionally
decoupled from any controller-logic, it just receives a set of search parameters
and an object class it acts on.
The default output of a SearchContext is either a SQLQuery object for
further refinement, or a DataObjectSet that can be used to display
search results, e.g. in a TableListField instance.
In case you need multiple contexts, consider namespacing your request parameters by using FieldSet->namespace() on the $fields constructor parameter.
Each DataObject subclass can have multiple search contexts for different
cases, e.g. for a limited frontend search and a fully featured backend search.
By default, you can use DataObject->getDefaultSearchContext() which
is automatically scaffolded. It uses DataObject::$searchable_fields to
determine which fields to include.
- Object
-
SearchContext
See: http://doc.silverstripe.com/doku.php?id=searchcontext
Used by:
BookingOrderAdmin Used by:
ImportCatalog1C_ProductProp_Admin Used by:
ModelAdmin Used by:
ModelAdmin::getModelForms() Used by:
MonumentAdmin Used by:
PaymentAdmin Used by:
ProductImport1CAdmin Used by:
ProductImportAdmin Used by:
RealtyImportAdmin Used by:
RedirectEntry_Admin Used by:
RoomServiceAdmin Used by:
VAT_Admin Used by:
VKNotificationQueueAdmin Located at sapphire/search/SearchContext.php
Methods summary
public
|
#
__construct( string $modelClass,
A key value pair of values that should be searched for. The keys should match
the field names specified in |
public
|
|
protected
|
|
public
|
|
public
|
#
getResults( array $searchParams, string|array $sort = false, string|array $limit = false )
Returns a result set from the given search parameters. |
public
boolean
|
#
clearEmptySearchFields( unknown_type $value )
Callback map function to filter fields with empty values from being included in the search expression. |
public
|
|
public
array
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
Methods inherited from Object
__call(),
__toString(),
__wakeup(),
addMethodsFrom(),
addStaticVars(),
addWrapperMethod(),
add_extension(),
add_static_var(),
allMethodNames(),
cacheToFile(),
cacheToFileWithArgs(),
clearCache(),
combined_static(),
create(),
createMethod(),
create_from_string(),
defineMethods(),
exists(),
extInstance(),
extend(),
getCustomClass(),
getExtensionInstance(),
getExtensionInstances(),
get_extensions(),
get_static(),
hasExtension(),
hasMethod(),
has_extension(),
invokeWithExtensions(),
is_a(),
loadCache(),
parentClass(),
parse_class_spec(),
remove_extension(),
sanitiseCachename(),
saveCache(),
set_stat(),
set_static(),
set_uninherited(),
stat(),
strong_create(),
uninherited(),
uninherited_static(),
useCustomClass()
Magic methods summary
Properties summary
protected
string
|
$modelClass |
#
DataObject subclass to which search parameters relate to. Also determines as which object each result is provided. |
protected
|
$fields |
#
FormFields mapping to |
protected
array
|
$filters |
#
Array of |
public
string
|
$connective |
#
The logical connective used to join WHERE clauses. Defaults to AND. |