class FulltextFilter extends SearchFilter (View source)

Filters by full-text matching on the given field.

The following column types are supported:

  • Char
  • Varchar
  • Text

To enable full-text matching on fields, you also need to add an index to the database table, using the {$indexes} hash in your DataObject subclass:

  private static $indexes = [
     'SearchFields' => [
         'type' => 'fulltext',
         'columns' => ['Name', 'Title', 'Description'],
  ];

Traits

A class that can be instantiated or replaced via DI

Provides extensions to this object to integrate it with standard config API methods.

Config options

default_case_sensitive bool|null

Whether search filters should be case sensitive or not by default.

from  SearchFilter

Properties

protected string $model

Classname of the inspected DataObject.

from  SearchFilter
protected string $name from  SearchFilter
protected string $fullName from  SearchFilter
protected mixed $value from  SearchFilter
protected array $modifiers from  SearchFilter
protected array $relation from  SearchFilter
protected array $aggregate

An array of data about an aggregate column being used ex: [ 'function' => 'COUNT', 'column' => 'ID' ]

from  SearchFilter

Methods

public static 
create(mixed ...$args)

An implementation of the factory method, allows you to create an instance of a class

public static 
singleton(string $class = null)

Creates a class instance by the "singleton" design pattern.

public static 
config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).

public
mixed
uninherited(string $name)

Gets the uninherited value for the given config option

public
__construct(string $fullName = null, mixed $value = false, array $modifiers = [])

No description

protected
addRelation(string $name)

Called by constructor to convert a string pathname into a well defined relationship sequence.

protected
addAggregate(string $name)

Parses the name for any aggregate functions and stores them in the $aggregate array

public
setModel(string|DataObject $className)

Set the root model class to be selected by this search query.

public
setValue(string|array $value)

Set the current value(s) to be filtered on.

public
string|array
getValue()

Accessor for the current value to be filtered on.

public
setModifiers(array $modifiers)

Set the current modifiers to apply to the filter

public
array
getSupportedModifiers()

Gets supported modifiers for this filter

public
array
getModifiers()

Accessor for the current modifiers to apply to the filter.

public
string
getName()

The original name of the field.

public
setName(string $name)

No description

public
string
getFullName()

The full name passed to the constructor, including any (optional) relations in dot notation.

public
setFullName(string $name)

No description

public
string
getDbName()

This implementation allows for a list of columns to be passed into MATCH() instead of just one.

public
string
getDbFormattedValue()

Return the value of the field as processed by the DBField class

public
applyAggregate(DataQuery $query, string $having)

Given an escaped HAVING clause, add it along with the appropriate GROUP BY clause

public
bool
matches(mixed $objectValue)

Check whether this filter matches against a value.

public
apply(DataQuery $query)

Apply filter criteria to a SQL query.

protected
applyOne(DataQuery $query)

Apply filter criteria to a SQL query with a single value.

protected
applyMany(DataQuery $query)

Apply filter criteria to a SQL query with an array of values.

public
exclude(DataQuery $query)

Exclude filter criteria from a SQL query.

protected
excludeOne(DataQuery $query)

Exclude filter criteria from a SQL query with a single value.

protected
excludeMany(DataQuery $query)

Exclude filter criteria from a SQL query with an array of values.

public
bool
isEmpty()

Determines if a field has a value, and that the filter should be applied.

protected
?bool
getCaseSensitive()

Determines case sensitivity based on getModifiers().

protected
bool|null
getCaseSensitiveByCollation()

Find out whether the database is set to use case sensitive comparisons or not by default.

protected
string
prepareColumns(array $columns)

Adds table identifier to the every column.

Details

static Injectable create(mixed ...$args)

An implementation of the factory method, allows you to create an instance of a class

This method will defer class substitution to the Injector API, which can be customised via the Config API to declare substitution classes.

This can be called in one of two ways - either calling via the class directly, or calling on Object and passing the class name as the first parameter. The following are equivalent: $list = DataList::create(SiteTree::class); $list = SiteTree::get();

Parameters

mixed ...$args

Return Value

Injectable

static Injectable singleton(string $class = null)

Creates a class instance by the "singleton" design pattern.

It will always return the same instance for this class, which can be used for performance reasons and as a simple way to access instance methods which don't rely on instance data (e.g. the custom SilverStripe static handling).

Parameters

string $class

Optional classname to create, if the called class should not be used

Return Value

Injectable

The singleton instance

static Config_ForClass config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).

Return Value

Config_ForClass

mixed uninherited(string $name)

Gets the uninherited value for the given config option

Parameters

string $name

Return Value

mixed

__construct(string $fullName = null, mixed $value = false, array $modifiers = [])

No description

Parameters

string $fullName

Determines the name of the field, as well as the searched database column. Can contain a relation name in dot notation, which will automatically join the necessary tables (e.g. "Comments.Name" to join the "Comments" has-many relationship and search the "Name" column when applying this filter to a SiteTree class).

mixed $value
array $modifiers

protected addRelation(string $name)

Called by constructor to convert a string pathname into a well defined relationship sequence.

Parameters

string $name

protected addAggregate(string $name)

Parses the name for any aggregate functions and stores them in the $aggregate array

Parameters

string $name

setModel(string|DataObject $className)

Set the root model class to be selected by this search query.

Parameters

string|DataObject $className

setValue(string|array $value)

Set the current value(s) to be filtered on.

Parameters

string|array $value

string|array getValue()

Accessor for the current value to be filtered on.

Return Value

string|array

setModifiers(array $modifiers)

Set the current modifiers to apply to the filter

Parameters

array $modifiers

array getSupportedModifiers()

Gets supported modifiers for this filter

Return Value

array

array getModifiers()

Accessor for the current modifiers to apply to the filter.

Return Value

array

string getName()

The original name of the field.

Return Value

string

setName(string $name)

No description

Parameters

string $name

string getFullName()

The full name passed to the constructor, including any (optional) relations in dot notation.

Return Value

string

setFullName(string $name)

No description

Parameters

string $name

string getDbName()

This implementation allows for a list of columns to be passed into MATCH() instead of just one.

Return Value

string

Exceptions

Exception

Examples

<code>
 MyDataObject::get()->filter('SearchFields:fulltext', 'search term')
</code>

string getDbFormattedValue()

Return the value of the field as processed by the DBField class

Return Value

string

DataQuery applyAggregate(DataQuery $query, string $having)

Given an escaped HAVING clause, add it along with the appropriate GROUP BY clause

Parameters

DataQuery $query
string $having

Return Value

DataQuery

bool matches(mixed $objectValue)

Check whether this filter matches against a value.

Parameters

mixed $objectValue

Return Value

bool

DataQuery apply(DataQuery $query)

Apply filter criteria to a SQL query.

Parameters

DataQuery $query

Return Value

DataQuery

protected DataQuery applyOne(DataQuery $query)

Apply filter criteria to a SQL query with a single value.

Parameters

DataQuery $query

Return Value

DataQuery

protected DataQuery applyMany(DataQuery $query)

Apply filter criteria to a SQL query with an array of values.

Parameters

DataQuery $query

Return Value

DataQuery

DataQuery exclude(DataQuery $query)

Exclude filter criteria from a SQL query.

Parameters

DataQuery $query

Return Value

DataQuery

protected DataQuery excludeOne(DataQuery $query)

Exclude filter criteria from a SQL query with a single value.

Parameters

DataQuery $query

Return Value

DataQuery

protected DataQuery excludeMany(DataQuery $query)

Exclude filter criteria from a SQL query with an array of values.

Parameters

DataQuery $query

Return Value

DataQuery

bool isEmpty()

Determines if a field has a value, and that the filter should be applied.

Relies on the field being populated with setValue()

Return Value

bool

protected ?bool getCaseSensitive()

Determines case sensitivity based on getModifiers().

Return Value

?bool

TRUE or FALSE to enforce sensitivity, NULL to use field collation.

protected bool|null getCaseSensitiveByCollation()

Find out whether the database is set to use case sensitive comparisons or not by default.

Used for static comparisons in the matches() method.

Return Value

bool|null

protected string prepareColumns(array $columns)

Adds table identifier to the every column.

Columns must have table identifier to prevent duplicate column name error.

Parameters

array $columns

Return Value

string