PHP Class Drest\Query\ExposeFields

Inheritance: implements Iterator
Afficher le fichier Open project: leedavis81/drest Class Usage Examples

Protected Properties

Свойство Type Description
$registered_expose_classes array Temporary used during processExposeDepth to prevent you traversing up and down bi-directional relations
$route Drest\Mapping\RouteMetaData The matched route
$route_expose array The route expose array - If explicitly set it overrides any default config settings

Méthodes publiques

Méthode Description
configureExposeDepth ( Drest\EntityManagerRegistry $emr, integer $exposureDepth, integer $exposureRelationsFetchType = null ) : ExposeFields Set the default exposure fields using the configured exposure depth
configurePullRequest ( array $requestOptions, DrestCommon\Request\Request $request ) : ExposeFields Configure the expose object to filter out fields that have been explicitly requested by the client.
configurePushRequest ( array $pushed ) : DrestCommon\ResultSet Configure the expose object to filter out fields that are not allowed to be use by the client.
create ( RouteMetaData $route ) : ExposeFields Create an instance of ExposeFields
current ( )
key ( )
next ( )
rewind ( )
toArray ( ) : array Get the expose fields
valid ( )

Méthodes protégées

Méthode Description
filterPushExpose ( array $requested, array $actual ) : array Filter out requested expose fields against what's allowed
filterRequestedExpose ( array &$requested, array &$actual ) Filter out requested expose fields against what's allowed
parseExposeString ( string $string ) : array An awesome solution was posted on (link below) to parse these using a regex http://stackoverflow.com/questions/16415558/regex-top-level-contents-from-a-string
processExposeDepth ( array &$fields, string $class, Drest\EntityManagerRegistry $emr, integer $depth, integer $fetchType = null ) Recursive function to generate default expose columns
recurseExposeString ( string $string, array &$results ) Recursively process the passed expose string

Private Methods

Méthode Description
__construct ( RouteMetaData $route ) Create an instance of ExposeFields - use create() method
parseStringParts ( string $string ) : stdClass Get information on parsed (top-level) brackets

Method Details

configureExposeDepth() public méthode

Set the default exposure fields using the configured exposure depth
public configureExposeDepth ( Drest\EntityManagerRegistry $emr, integer $exposureDepth, integer $exposureRelationsFetchType = null ) : ExposeFields
$emr Drest\EntityManagerRegistry
$exposureDepth integer
$exposureRelationsFetchType integer
Résultat ExposeFields $this object instance

configurePullRequest() public méthode

This is only applicable for a HTTP pull (GET) call. For configuring
public configurePullRequest ( array $requestOptions, DrestCommon\Request\Request $request ) : ExposeFields
$requestOptions array
$request DrestCommon\Request\Request
Résultat ExposeFields $this object instance

configurePushRequest() public méthode

Unlike the configuring of the Pull request, this function will return the formatted array in a ResultSet object This is only applicable for a HTTP push (POST/PUT/PATCH) call
public configurePushRequest ( array $pushed ) : DrestCommon\ResultSet
$pushed array - the data push on the request
Résultat DrestCommon\ResultSet

create() public static méthode

Create an instance of ExposeFields
public static create ( RouteMetaData $route ) : ExposeFields
$route Drest\Mapping\RouteMetaData - requires a matched route
Résultat ExposeFields

current() public méthode

public current ( )

filterPushExpose() protected méthode

Filter out requested expose fields against what's allowed
protected filterPushExpose ( array $requested, array $actual ) : array
$requested array - The requested expose definition
$actual array - current allowed expose definition
Résultat array $request - The requested expose data with non-allowed data stripped off

filterRequestedExpose() protected méthode

Filter out requested expose fields against what's allowed
protected filterRequestedExpose ( array &$requested, array &$actual )
$requested array - The requested expose definition - invalid / not allowed data is stripped off
$actual array - current allowed expose definition

key() public méthode

public key ( )

next() public méthode

public next ( )

parseExposeString() protected méthode

preg_match_all( '/(?<=\[) # Assert that the previous characters is a [ (?: # Match either... [^[\]]* # any number of characters except brackets | # or \[ # an opening bracket (?R) # containing a match of this very regex \] # followed by a closing bracket )* # Repeat as needed (?=\]) # Assert the next character is a ]/x', $string, $result, PREG_PATTERN_ORDER);
protected parseExposeString ( string $string ) : array
$string string
Résultat array $result

processExposeDepth() protected méthode

Recursive function to generate default expose columns
protected processExposeDepth ( array &$fields, string $class, Drest\EntityManagerRegistry $emr, integer $depth, integer $fetchType = null )
$fields array - array to be populated recursively (referenced)
$class string - name of the class to process
$emr Drest\EntityManagerRegistry - entity manager registry used to fetch class information
$depth integer - maximum depth you want to travel through the relations
$fetchType integer - The fetch type to be used

recurseExposeString() protected méthode

Recursively process the passed expose string
protected recurseExposeString ( string $string, array &$results )
$string string - the string to be processed
$results array - passed by reference

rewind() public méthode

public rewind ( )

toArray() public méthode

Get the expose fields
public toArray ( ) : array
Résultat array $fields

valid() public méthode

public valid ( )

Property Details

$registered_expose_classes protected_oe property

Temporary used during processExposeDepth to prevent you traversing up and down bi-directional relations
protected array $registered_expose_classes
Résultat array

$route protected_oe property

The matched route
protected RouteMetaData,Drest\Mapping $route
Résultat Drest\Mapping\RouteMetaData

$route_expose protected_oe property

The route expose array - If explicitly set it overrides any default config settings
protected array $route_expose
Résultat array