class SearchCriteria implements SearchCriteriaInterface (View source)

Class SearchCriteria

Constants

CONJUNCTION_AND

CONJUNCTION_OR

Properties

protected SearchCriteriaInterface[] $clauses

A collection of SearchCriterion and SearchCriteria.

protected string[] $conjunctions

The conjunctions used between Criteria (AND/OR).

protected SearchAdapterInterface|null $adapter

Methods

public
__construct(string|SearchCriterion $target, mixed $value = null, string|null $comparison = null, AbstractSearchQueryWriter $searchQueryWriter = null)

You can pass through a string value, Criteria object, or Criterion object for $target.

public static 
create($target, null $value = null, null $comparison = null, AbstractSearchQueryWriter $searchQueryWriter = null)

Static create method provided so that you can perform method chaining.

public
getAdapter()

No description

public
$this
setAdapter(SearchAdapterInterface $adapter)

No description

public
void
appendPreparedStatementTo($ps)

No description

public
$this
addAnd(string|SearchCriteriaInterface $target, mixed $value = null, string|null $comparison = null, AbstractSearchQueryWriter $searchQueryWriter = null)

No description

public
$this
addOr(string|SearchCriteriaInterface $target, mixed $value = null, string|null $comparison = null, AbstractSearchQueryWriter $searchQueryWriter = null)

No description

protected
getCriterionForCondition(string|SearchCriteriaInterface $target, mixed $value, string $comparison, AbstractSearchQueryWriter $searchQueryWriter = null)

No description

protected
getClauses()

No description

protected
addClause(SearchCriteriaInterface $criterion)

No description

protected
string[]
getConjunctions()

No description

protected
string|null
getConjunction(int $key)

No description

protected
addConjunction(string $conjunction)

No description

Details

__construct(string|SearchCriterion $target, mixed $value = null, string|null $comparison = null, AbstractSearchQueryWriter $searchQueryWriter = null)

You can pass through a string value, Criteria object, or Criterion object for $target.

String value might be "SiteTree_Title" or whatever field in your index that you're trying to target.

If you require complex filtering then you can build your Criteria object first with multiple layers/levels of Criteria, and then pass it in here when you're ready.

If you have your own Criterion object that you've created that you want to use, you can also pass that in here.

Parameters

string|SearchCriterion $target
mixed $value
string|null $comparison
AbstractSearchQueryWriter $searchQueryWriter

static SearchCriteria create($target, null $value = null, null $comparison = null, AbstractSearchQueryWriter $searchQueryWriter = null)

Static create method provided so that you can perform method chaining.

Parameters

$target
null $value
null $comparison
AbstractSearchQueryWriter $searchQueryWriter

Return Value

SearchCriteria

SearchAdapterInterface getAdapter()

No description

Return Value

SearchAdapterInterface

$this setAdapter(SearchAdapterInterface $adapter)

No description

Parameters

SearchAdapterInterface $adapter

Return Value

$this

void appendPreparedStatementTo($ps)

No description

Parameters

$ps

Return Value

void

Exceptions

Exception

$this addAnd(string|SearchCriteriaInterface $target, mixed $value = null, string|null $comparison = null, AbstractSearchQueryWriter $searchQueryWriter = null)

No description

Parameters

string|SearchCriteriaInterface $target
mixed $value
string|null $comparison
AbstractSearchQueryWriter $searchQueryWriter

Return Value

$this

$this addOr(string|SearchCriteriaInterface $target, mixed $value = null, string|null $comparison = null, AbstractSearchQueryWriter $searchQueryWriter = null)

No description

Parameters

string|SearchCriteriaInterface $target
mixed $value
string|null $comparison
AbstractSearchQueryWriter $searchQueryWriter

Return Value

$this

protected SearchCriteriaInterface getCriterionForCondition(string|SearchCriteriaInterface $target, mixed $value, string $comparison, AbstractSearchQueryWriter $searchQueryWriter = null)

No description

Parameters

string|SearchCriteriaInterface $target
mixed $value
string $comparison
AbstractSearchQueryWriter $searchQueryWriter

Return Value

SearchCriteriaInterface

protected SearchCriteriaInterface[] getClauses()

No description

Return Value

SearchCriteriaInterface[]

protected addClause(SearchCriteriaInterface $criterion)

No description

Parameters

SearchCriteriaInterface $criterion

protected string[] getConjunctions()

No description

Return Value

string[]

protected string|null getConjunction(int $key)

No description

Parameters

int $key

Return Value

string|null

protected addConjunction(string $conjunction)

No description

Parameters

string $conjunction