PHP Class Bolt\Storage\Query\QueryParameterParser

@author Ross Riley
Afficher le fichier Open project: bolt/bolt Class Usage Examples

Méthodes publiques

Свойство Type Description
$alias string

Protected Properties

Свойство Type Description
$expr Doctrine\DBAL\Query\Expression\ExpressionBuilder
$filterHandlers Filter[]
$key string
$value mixed
$valueMatchers array

Méthodes publiques

Méthode 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 méthode

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

addFilterHandler() public méthode

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 méthode

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 méthode

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
Résultat Filter

getFilter() public méthode

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

incorrectQueryHandler() public méthode

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 méthode

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
Résultat Filter | null

multipleValueHandler() public méthode

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
Résultat Filter | null

parseValue() public méthode

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
Résultat array Parsed values

setAlias() public méthode

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

setupDefaults() public méthode

public setupDefaults ( )

Property Details

$alias public_oe property

public string $alias
Résultat string

$expr protected_oe property

protected ExpressionBuilder,Doctrine\DBAL\Query\Expression $expr
Résultat Doctrine\DBAL\Query\Expression\ExpressionBuilder

$filterHandlers protected_oe property

protected Filter[],Bolt\Storage\Query $filterHandlers
Résultat Filter[]

$key protected_oe property

protected string $key
Résultat string

$value protected_oe property

protected mixed $value
Résultat mixed

$valueMatchers protected_oe property

protected array $valueMatchers
Résultat array