PHP Class Bolt\Storage\Query\QueryParameterParser

@author Ross Riley
Show file Open project: bolt/bolt Class Usage Examples

Public Properties

Property Type Description
$alias string

Protected Properties

Property Type Description
$expr Doctrine\DBAL\Query\Expression\ExpressionBuilder
$filterHandlers Filter[]
$key string
$value mixed
$valueMatchers array

Public Methods

Method Description
__construct ( Doctrine\DBAL\Query\Expression\ExpressionBuilder $expr = null ) Constructor.
addFilterHandler ( callable $handler ) The goal of this class is to turn any key:value into a Filter class.
addValueMatcher ( string $token, array $params = [], boolean $priority = null ) Adds an additional token to parse for value parameters.
defaultFilterHandler ( string $key, string $value, Doctrine\DBAL\Query\Expression\ExpressionBuilder $expr ) : Filter The default handler is the last to be run and handler simple value parsing.
getFilter ( string $key, mixed $value = null ) : Filter | null Runs the keys/values through the relevant parsers.
incorrectQueryHandler ( string $key, string $value, Doctrine\DBAL\Query\Expression\ExpressionBuilder $expr ) Handles some errors in key/value string formatting.
multipleKeyAndValueHandler ( string $key, string $value, Doctrine\DBAL\Query\Expression\ExpressionBuilder $expr ) : Filter | null 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'.
multipleValueHandler ( string $key, string $value, Doctrine\DBAL\Query\Expression\ExpressionBuilder $expr ) : Filter | null 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.
parseValue ( string $value ) : array This method uses the defined value matchers to parse a passed in value to the following component parts: [ 'value' => 'operator' => 'matched' => ]
setAlias ( string $alias ) Sets the select alias to be used in sql queries.
setupDefaults ( )

Method Details

__construct() public method

Constructor.
public __construct ( Doctrine\DBAL\Query\Expression\ExpressionBuilder $expr = null )
$expr Doctrine\DBAL\Query\Expression\ExpressionBuilder

addFilterHandler() public method

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\Query\Filter
public addFilterHandler ( callable $handler )
$handler callable

addValueMatcher() public method

This gives the ability to define additional value -> operator matches
public addValueMatcher ( string $token, array $params = [], boolean $priority = null )
$token string Regex pattern to match against
$params array Options to provide to the matched param
$priority boolean If set item will be prepended to start of list

defaultFilterHandler() public method

The default handler is the last to be run and handler simple value parsing.
public defaultFilterHandler ( string $key, string $value, Doctrine\DBAL\Query\Expression\ExpressionBuilder $expr ) : Filter
$key string
$value string
$expr Doctrine\DBAL\Query\Expression\ExpressionBuilder
return Filter

getFilter() public method

Runs the keys/values through the relevant parsers.
public getFilter ( string $key, mixed $value = null ) : Filter | null
$key string
$value mixed
return Filter | null

incorrectQueryHandler() public method

Handles some errors in key/value string formatting.
public incorrectQueryHandler ( string $key, string $value, Doctrine\DBAL\Query\Expression\ExpressionBuilder $expr )
$key string
$value string
$expr Doctrine\DBAL\Query\Expression\ExpressionBuilder

multipleKeyAndValueHandler() public method

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'.
public multipleKeyAndValueHandler ( string $key, string $value, Doctrine\DBAL\Query\Expression\ExpressionBuilder $expr ) : Filter | null
$key string
$value string
$expr Doctrine\DBAL\Query\Expression\ExpressionBuilder
return Filter | null

multipleValueHandler() public method

For example, this handler will correctly parse values like: 'username': 'fred||bob' 'id': '<5 && !1'
public multipleValueHandler ( string $key, string $value, Doctrine\DBAL\Query\Expression\ExpressionBuilder $expr ) : Filter | null
$key string
$value string
$expr Doctrine\DBAL\Query\Expression\ExpressionBuilder
return Filter | null

parseValue() public method

This method uses the defined value matchers to parse a passed in value to the following component parts: [ 'value' => 'operator' => 'matched' => ]
public parseValue ( string $value ) : array
$value string Value to process
return array Parsed values

setAlias() public method

Sets the select alias to be used in sql queries.
public setAlias ( string $alias )
$alias string

setupDefaults() public method

public setupDefaults ( )

Property Details

$alias public property

public string $alias
return string

$expr protected property

protected ExpressionBuilder,Doctrine\DBAL\Query\Expression $expr
return Doctrine\DBAL\Query\Expression\ExpressionBuilder

$filterHandlers protected property

protected Filter[],Bolt\Storage\Query $filterHandlers
return Filter[]

$key protected property

protected string $key
return string

$value protected property

protected mixed $value
return mixed

$valueMatchers protected property

protected array $valueMatchers
return array