QueryParameterParser
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
Constructor.
No description
Sets the select alias to be used in sql queries.
Runs the keys/values through the relevant parsers.
Handles some errors in key/value string formatting.
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'.
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.
The default handler is the last to be run and handles simple value parsing.
This method uses the defined value matchers to parse a passed in value.
The goal of this class is to turn any key:value into a Filter class.
Adds an additional token to parse for value parameters.
Details
__construct(Expr $expr)
Constructor.
void
setupDefaults()
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.
For example, this handler will correctly parse values like: 'username': 'fred||bob' 'id': '<5 && !1'
Filter
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.
The following component parts will be returned in the array:
[
'value' =>
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
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