PHP Class Bolt\Storage\Query\ContentQueryParser

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

Protected Properties

Property Type Description
$contentTypes array
$directiveHandlers callable[]
$directives array
$em Bolt\Storage\EntityManager
$handlers callable[]
$identifier string
$operation string
$operations array
$params array
$query string
$services Bolt\Storage\Query\QueryInterface[]

Public Methods

Method Description
__construct ( EntityManager $em, Bolt\Storage\Query\QueryInterface $queryHandler = null ) Constructor.
addDirectiveHandler ( string $key, callable $callback = null ) Adds a handler for the named directive.
addHandler ( string $operation, callable $callback ) Adds a handler AND operation for the named operation.
addOperation ( string $operation ) Adds a new operation to the list supported.
addService ( string $operation, Bolt\Storage\Query\QueryInterface $service ) Adds a service for the named operation.
fetch ( ) : QueryResultset Runs the query and fetches the results.
getContentTypes ( ) : array Returns the parsed content types.
getDirective ( string $key ) : string Returns a directive from the parsed list.
getDirectiveHandler ( string $check ) : callable Returns the handler for the named directive.
getEntityManager ( ) : EntityManager Gets the object EntityManager
getHandler ( string $operation ) : callable Returns a handler for the named operation.
getIdentifier ( ) : string Returns the parsed identifier.
getOperation ( ) : string Returns the parsed operation.
getOperations ( ) : array Getter to return the currently registered operations.
getParameter ( string $param ) : array Returns a single named parameter.
getParameters ( ) : array Returns the current parameters.
getService ( string $operation ) : Bolt\Storage\Query\QueryInterface Returns a service for the named operation.
hasDirectiveHandler ( string $check ) : boolean Returns boolean for existence of handler.
parse ( ) Parse a query.
removeOperation ( string $operation ) Removes an operation from the list supported.
runDirectives ( Bolt\Storage\Query\QueryInterface $query, array $skipDirective = [] ) This runs the callbacks attached to each directive command.
setDirective ( string $key, mixed $value ) Sets a directive for the named key.
setParameter ( string $param, mixed $value ) Sets a single input parameter.
setParameters ( array $params ) Sets the input parameters to handle.
setQuery ( string $query ) Sets the input query.

Protected Methods

Method Description
parseContent ( ) Parses the content area of the querystring.
parseDirectives ( ) Directives are all of the other parameters supported by Bolt that do not relate to an actual filter query. Some examples include 'printquery', 'limit', 'order' or 'returnsingle'.
parseOperation ( ) Internal method that takes the 'query' part of the input and parses it into one of the various operations supported.
setupDefaults ( ) Internal method to initialise the default handlers.

Method Details

__construct() public method

Constructor.
public __construct ( EntityManager $em, Bolt\Storage\Query\QueryInterface $queryHandler = null )
$em Bolt\Storage\EntityManager
$queryHandler Bolt\Storage\Query\QueryInterface

addDirectiveHandler() public method

Adds a handler for the named directive.
public addDirectiveHandler ( string $key, callable $callback = null )
$key string
$callback callable

addHandler() public method

Adds a handler AND operation for the named operation.
public addHandler ( string $operation, callable $callback )
$operation string
$callback callable

addOperation() public method

Adds a new operation to the list supported.
public addOperation ( string $operation )
$operation string name of operation to parse for

addService() public method

Adds a service for the named operation.
public addService ( string $operation, Bolt\Storage\Query\QueryInterface $service )
$operation string
$service Bolt\Storage\Query\QueryInterface

fetch() public method

Runs the query and fetches the results.
public fetch ( ) : QueryResultset
return QueryResultset

getContentTypes() public method

Returns the parsed content types.
public getContentTypes ( ) : array
return array

getDirective() public method

Returns a directive from the parsed list.
public getDirective ( string $key ) : string
$key string
return string

getDirectiveHandler() public method

Returns the handler for the named directive.
public getDirectiveHandler ( string $check ) : callable
$check string
return callable

getEntityManager() public method

Gets the object EntityManager
public getEntityManager ( ) : EntityManager
return Bolt\Storage\EntityManager

getHandler() public method

Returns a handler for the named operation.
public getHandler ( string $operation ) : callable
$operation string
return callable

getIdentifier() public method

Returns the parsed identifier.
public getIdentifier ( ) : string
return string

getOperation() public method

Returns the parsed operation.
public getOperation ( ) : string
return string

getOperations() public method

Getter to return the currently registered operations.
public getOperations ( ) : array
return array

getParameter() public method

Returns a single named parameter.
public getParameter ( string $param ) : array
$param string
return array

getParameters() public method

Returns the current parameters.
public getParameters ( ) : array
return array

getService() public method

Returns a service for the named operation.
public getService ( string $operation ) : Bolt\Storage\Query\QueryInterface
$operation string
return Bolt\Storage\Query\QueryInterface

hasDirectiveHandler() public method

Returns boolean for existence of handler.
public hasDirectiveHandler ( string $check ) : boolean
$check string
return boolean

parse() public method

Parse a query.
public parse ( )

parseContent() protected method

Parses the content area of the querystring.
protected parseContent ( )

parseDirectives() protected method

All these need to parsed and taken out of the params that are sent to the query.
protected parseDirectives ( )

parseOperation() protected method

A simple select operation will just contain the ContentType eg 'pages' but additional operations can be triggered using the '/' separator.
protected parseOperation ( )

removeOperation() public method

Removes an operation from the list supported.
public removeOperation ( string $operation )
$operation string name of operation to remove

runDirectives() public method

This runs the callbacks attached to each directive command.
public runDirectives ( Bolt\Storage\Query\QueryInterface $query, array $skipDirective = [] )
$query Bolt\Storage\Query\QueryInterface
$skipDirective array

setDirective() public method

Sets a directive for the named key.
public setDirective ( string $key, mixed $value )
$key string
$value mixed

setParameter() public method

Sets a single input parameter.
public setParameter ( string $param, mixed $value )
$param string
$value mixed

setParameters() public method

Sets the input parameters to handle.
public setParameters ( array $params )
$params array

setQuery() public method

Sets the input query.
public setQuery ( string $query )
$query string

setupDefaults() protected method

Internal method to initialise the default handlers.
protected setupDefaults ( )

Property Details

$contentTypes protected_oe property

protected array $contentTypes
return array

$directiveHandlers protected_oe property

protected callable[] $directiveHandlers
return callable[]

$directives protected_oe property

protected array $directives
return array

$em protected_oe property

protected EntityManager,Bolt\Storage $em
return Bolt\Storage\EntityManager

$handlers protected_oe property

protected callable[] $handlers
return callable[]

$identifier protected_oe property

protected string $identifier
return string

$operation protected_oe property

protected string $operation
return string

$operations protected_oe property

protected array $operations
return array

$params protected_oe property

protected array $params
return array

$query protected_oe property

protected string $query
return string

$services protected_oe property

protected QueryInterface[],Bolt\Storage\Query $services
return Bolt\Storage\Query\QueryInterface[]