\Search\Model\SearchGenericOperator

Generic handler for any search operator.

For instance:

operator_name:operator_value

Summary

Methods
Properties
Constants
scope()
__construct()
No public properties found
No constants found
_prepareConjunction()
$_defaultConfig
$_table
N/A
No private methods found
No private properties found
N/A

Properties

$_defaultConfig

$_defaultConfig : array

Default configuration for this operator.

Type

array

$_table

$_table : \Cake\ORM\Table

The table for which handle this operator.

Type

\Cake\ORM\Table

Methods

scope()

scope(\Cake\ORM\Query $query, \Search\Token $token) : \Cake\ORM\Query

Alters the given query and applies this operator's filter conditions.

Parameters

\Cake\ORM\Query $query

The query to alter

\Search\Token $token

Token representing this operator. Frequently used methods are:

  • Token::value(): The value for this operator, that is whatever comes after : symbol. e.g. JohnLocke for criteria author:JohnLocke
  • Token::negated(): True if user has negated this operator using the - symbol. e.g.: -author:JohnLocke. False otherwise.
  • Token::where(): Possible values are "or", "and" and null. Indicates the type of WHERE condition that should be used when scoping using this token, for instance, OR author:JohnLocke will return or. But, AND author:JohnLocke will return and. By default it is set to NULL. This allows you to use Query::andWhere() and Query::orWhere() methods as needed.

Returns

\Cake\ORM\Query —

Altered query

__construct()

__construct(\Cake\ORM\Table $table, array $config)

Operator constructor.

Parameters

\Cake\ORM\Table $table

The table for which handle this operator

array $config

Additional configuration options for this particular operator

_prepareConjunction()

_prepareConjunction(\Search\Token $token) : array

Calculates the conjunction to use and the value to use with such conjunction based on the given token.

Parameters

\Search\Token $token

Token for which calculating the conjunction

Returns

array —

Numeric index array, where the first key (0) is the conjunction, and the second (1) is the value.