class QueryParameterParser (View source)

Handler class to convert the DSL for content query parameters into equivalent ORM expressions.

Properties

string $alias
protected string $key
protected mixed $value
protected Expr $expr
protected array $valueMatchers
protected Filter[] $filterHandlers

Methods

__construct(Expr $expr)

Constructor.

void
setupDefaults()

No description

void
setAlias(string $alias)

Sets the select alias to be used in sql queries.

Filter|null
getFilter(string $key, $value = null)

Runs the keys/values through the relevant parsers.

incorrectQueryHandler(string $key, $value, Expr $expr)

Handles some errors in key/value string formatting.

Filter|null
multipleKeyAndValueHandler(string $key, $value, Expr $expr)

This handler processes 'triple pipe' queries as implemented in Bolt It looks for three pipes in the key and value and creates an OR composite expression for example: 'username|||email':'fred|||pete'.

Filter|null
multipleValueHandler(string $key, $value, Expr $expr)

This handler processes multiple value queries as defined in the Bolt 'Fetching Content' documentation. It allows a value to be parsed to and AND/OR expression.

defaultFilterHandler(string $key, $value, Expr $expr)

The default handler is the last to be run and handles simple value parsing.

array
parseValue(string $value)

This method uses the defined value matchers to parse a passed in value.

void
addFilterHandler(callable $handler)

The goal of this class is to turn any key:value into a Filter class.

void
addValueMatcher(string $token, array $params = [], bool $priority = null)

Adds an additional token to parse for value parameters.

Details

__construct(Expr $expr)

Constructor.

Parameters

Expr $expr

void setupDefaults()

Return Value

void

void setAlias(string $alias)

Sets the select alias to be used in sql queries.

Parameters

string $alias

Return Value

void

Filter|null getFilter(string $key, $value = null)

Runs the keys/values through the relevant parsers.

Parameters

string $key
$value

Return Value

Filter|null

incorrectQueryHandler(string $key, $value, Expr $expr)

Handles some errors in key/value string formatting.

Parameters

string $key
$value
Expr $expr

Filter|null multipleKeyAndValueHandler(string $key, $value, Expr $expr)

This handler processes 'triple pipe' queries as implemented in Bolt It looks for three pipes in the key and value and creates an OR composite expression for example: 'username|||email':'fred|||pete'.

Parameters

string $key
$value
Expr $expr

Return Value

Filter|null

Filter|null multipleValueHandler(string $key, $value, Expr $expr)

This handler processes multiple value queries as defined in the Bolt 'Fetching Content' documentation. It allows a value to be parsed to and AND/OR expression.

For example, this handler will correctly parse values like: 'username': 'fred||bob' 'id': '<5 && !1'

Parameters

string $key
$value
Expr $expr

Return Value

Filter|null

Filter defaultFilterHandler(string $key, $value, Expr $expr)

The default handler is the last to be run and handles simple value parsing.

Parameters

string $key
$value
Expr $expr

Return Value

Filter

array parseValue(string $value)

This method uses the defined value matchers to parse a passed in value.

The following component parts will be returned in the array: [ 'value' => 'operator' => 'matched' => ]

Parameters

string $value

Return Value

array

void addFilterHandler(callable $handler)

The goal of this class is to turn any key:value into a Filter class.

Adding a handler here will push the new filter callback onto the top of the Queue along with the built in defaults.

Note: the callback should either return nothing or an instance of \Bolt\Storage\Filter

Parameters

callable $handler

Return Value

void

void addValueMatcher(string $token, array $params = [], bool $priority = null)

Adds an additional token to parse for value parameters.

This gives the ability to define additional value -> operator matches

Parameters

string $token Regex pattern to match against
array $params Options to provide to the matched param
bool $priority If set item will be prepended to start of list

Return Value

void