PHP Class Marcelgwerder\ApiHandler\Parser

Exibir arquivo Open project: marcelgwerder/laravel-api-handler Class Usage Examples

Public Properties

Property Type Description
$builder mixed The builder Instance.
$envelope boolean If the response should be in an envelope or not
$meta array The parsed meta information
$mode string The mode for the response (count,default)
$multiple boolean If the parser works on multiple datasets
$originalBuilder mixed The original builder Instance.

Protected Properties

Property Type Description
$additionalFields array All fields that belong to a relation
$additionalSorts array All sorts that belong to a relation
$functionalParams All functional params
$functions array Predefined functions
$isEloquentBuilder boolean If builder is an eloquent builder or not
$isQueryBuilder boolean If builder is an query builder or not
$originalQuery Illuminate\Database\Query\Builder The original query builder instance.
$params array The http query params.
$query Illuminate\Database\Query\Builder The base query builder instance.

Public Methods

Method Description
__construct ( mixed $builder, array $params ) Instantiate the Parser class
parse ( mixed $options, boolean $multiple = false ) : void Parse the query parameters with the given options.
setConfigHandler ( mixed $config ) Set the config object

Protected Methods

Method Description
getFilterParams ( ) : array | boolean Get the relevant filter parameters
getParam ( string $param ) : string | boolean Get a parameter
getRelationType ( Illuminate\Database\Eloquent\Relations\Relation $relation ) : string Determine the type of the Eloquent relation
isRelation ( Illuminate\Database\Eloquent\Model $model, string $relationName ) : boolean Check if there exists a method marked with the "@Relation" annotation on the given model.
parseConfig ( $configParam ) : void Parse the meta parameter and prepare an array of meta provider objects.
parseFields ( string $fieldsParam ) : void Parse the fields parameter and return an array of fields
parseFilter ( array $filterParams ) : void Parse the remaining filter params
parseFullTextSearch ( string $qParam, array $fullTextSearchColumns ) : void Parse the fulltext search parameter q
parseSort ( string $sortParam ) : void Parse the sort param and determine whether the sorting is ascending or descending.
parseWith ( string $withParam ) : void Parse the with parameter

Method Details

__construct() public method

Instantiate the Parser class
public __construct ( mixed $builder, array $params )
$builder mixed
$params array

getFilterParams() protected method

Get the relevant filter parameters
protected getFilterParams ( ) : array | boolean
return array | boolean

getParam() protected method

Get a parameter
protected getParam ( string $param ) : string | boolean
$param string
return string | boolean

getRelationType() protected method

Determine the type of the Eloquent relation
protected getRelationType ( Illuminate\Database\Eloquent\Relations\Relation $relation ) : string
$relation Illuminate\Database\Eloquent\Relations\Relation
return string

isRelation() protected method

Check if there exists a method marked with the "@Relation" annotation on the given model.
protected isRelation ( Illuminate\Database\Eloquent\Model $model, string $relationName ) : boolean
$model Illuminate\Database\Eloquent\Model
$relationName string
return boolean

parse() public method

Either for a single dataset or multiple.
public parse ( mixed $options, boolean $multiple = false ) : void
$options mixed
$multiple boolean
return void

parseConfig() protected method

Parse the meta parameter and prepare an array of meta provider objects.
protected parseConfig ( $configParam ) : void
return void

parseFields() protected method

Parse the fields parameter and return an array of fields
protected parseFields ( string $fieldsParam ) : void
$fieldsParam string
return void

parseFilter() protected method

Parse the remaining filter params
protected parseFilter ( array $filterParams ) : void
$filterParams array
return void

parseFullTextSearch() protected method

Parse the fulltext search parameter q
protected parseFullTextSearch ( string $qParam, array $fullTextSearchColumns ) : void
$qParam string
$fullTextSearchColumns array
return void

parseSort() protected method

A descending sort has a leading "-". Apply it to the query.
protected parseSort ( string $sortParam ) : void
$sortParam string
return void

parseWith() protected method

Parse the with parameter
protected parseWith ( string $withParam ) : void
$withParam string
return void

setConfigHandler() public method

Set the config object
public setConfigHandler ( mixed $config )
$config mixed

Property Details

$additionalFields protected_oe property

All fields that belong to a relation
protected array $additionalFields
return array

$additionalSorts protected_oe property

All sorts that belong to a relation
protected array $additionalSorts
return array

$builder public_oe property

The builder Instance.
public mixed $builder
return mixed

$envelope public_oe property

If the response should be in an envelope or not
public bool $envelope
return boolean

$functionalParams protected_oe property

All functional params
protected $functionalParams

$functions protected_oe property

Predefined functions
protected array $functions
return array

$isEloquentBuilder protected_oe property

If builder is an eloquent builder or not
protected bool $isEloquentBuilder
return boolean

$isQueryBuilder protected_oe property

If builder is an query builder or not
protected bool $isQueryBuilder
return boolean

$meta public_oe property

The parsed meta information
public array $meta
return array

$mode public_oe property

The mode for the response (count,default)
public string $mode
return string

$multiple public_oe property

If the parser works on multiple datasets
public bool $multiple
return boolean

$originalBuilder public_oe property

The original builder Instance.
public mixed $originalBuilder
return mixed

$originalQuery protected_oe property

The original query builder instance.
protected Builder,Illuminate\Database\Query $originalQuery
return Illuminate\Database\Query\Builder

$params protected_oe property

The http query params.
protected array $params
return array

$query protected_oe property

The base query builder instance.
protected Builder,Illuminate\Database\Query $query
return Illuminate\Database\Query\Builder