\Search\Model\SearchDateOperator

Handles date ranges operators.

For instance:

created:<date>
created:<date1>..<date2>

Dates must be in YEAR-MONTH-DATE format. e.g. 2014-12-30

Summary

Methods
Properties
Constants
scope()
__construct()
No public properties found
No constants found
_parseRange()
_normalize()
$_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

_parseRange()

_parseRange(string $value) : array

Parses and extracts lower and upper values from the given range given as `lower.

.upper`.

Parameters

string $value

A values range given as <lowerValue>..<upperValue>. For instance. 100..200

Returns

array —

Associative array with two keys: lower and upper

_normalize()

_normalize(string $date) : string

Normalizes the given date.

Parameters

string $date

Date to normalize

Returns

string —

Date formated as Y-m-d