PHP Class Drest\Mapping\RouteMetaData

Author: Lee
Inheritance: implements Serializable
Datei anzeigen Open project: leedavis81/drest Class Usage Examples

Protected Properties

Property Type Description
$allowed_option_request integer Whether this route is open to allow OPTION requests to detail available $verbs -1 = not set 0 = not allowed 1 = allowed
$class_metadata Drest\Mapping\ClassMetaData This route objects parent
$collection boolean Whether get requests to this route should be exposed / handled as collections
$disable_expose boolean Prevent expose settings lookup
$expose array An array of fields to be exposed to the end client
$handle_call string A handle function call for this route (if one is configured)
$name string The route name (must be unique)
$param_names array Key-value array of URL parameter names
$param_names_path array Key-value array of URL parameters with + at the end
$route_conditions array Eg array('year' => '(19|20)\d\d')
$route_params array Key-value array of URL parameters populated after a match has been successful - or directly by using available setter
$route_pattern string A string route pattern to be matched on. eg /user/:id
$unmapped_route_params array The value id => 1 will go into $route_params All the rest will go in here.
$verbs array They match the constant values defined in DrestCommon\Request\Request eg array('GET', 'POST')

Public Methods

Method Description
getClassMetaData ( ) : Drest\Mapping\ClassMetaData Get this classes metadata object
getExpose ( ) : array Get the field exposure on this route
getHandleCall ( ) : string Get the handle call function
getName ( ) : string Get the name of this route
getNamedRoute ( ) : string The unique named route to reference this route by Note that is should use the entities fully qualified class names
getOriginLocation ( object $object, string $url, EntityManager $em = null ) : string | false Generate the location string from the provided object
getRouteConditions ( ) : array | null Get the route conditions
getRouteParams ( ) : array Get any params that were set after a successful match
getRoutePattern ( ) : string Get this routes route pattern
getVerbs ( ) : array Get an array of verbs that are allowed on this route
hasHandleCall ( ) Does this route have an annotated handle call
isAllowedOptionRequest ( ) : integer Is this route allowed to expose its verbs to OPTIONS requests
isCollection ( ) Should this route be handled as a collection
isExposeDisabled ( ) : boolean Is the expose lookup disabled
matches ( DrestCommon\Request\Request $request, boolean $matchVerb = true, string $basePath = null ) : boolean Does this request match the route pattern
needsHandleCall ( ) : boolean Does this route need a handle call? Required for POST/PUT/PATCH verbs
serialize ( ) : string Serialise this object
setAllowedOptionRequest ( integer | boolean $value = true ) Set whether we would like to expose this route (and its verbs) to OPTIONS requests
setClassMetaData ( Drest\Mapping\ClassMetaData $class_metadata ) Set this objects parent metadata class
setCollection ( boolean $value = true ) Whether requests to this route should be handled as collections
setDisableExpose ( boolean $flag = true ) Set disable expose flag
setExpose ( array $expose ) An array of fields we're allowed to expose to the client
setHandleCall ( string $handle_call ) Set the handle function call
setName ( string $name ) Sets a unique reference name for the resource.
setRouteConditions ( array $route_conditions ) Add an array of route conditions
setRouteParams ( array $params = [] ) Inject route params onto this object without performing a match. Useful when calling a named route directly
setRoutePattern ( string $route_pattern ) Add the route path. eg '/users/:id'
setUnmappedRouteParams ( array $params = [] ) Inject unmapped route params onto this object without performing a match.
setVerbs ( mixed $verbs ) Add verbs that are to be allowed on this route.
unserialize ( string $string ) Un-serialise this object and reestablish it's state
usesHttpVerbs ( ) Is this route specific to defined HTTP verbs

Method Details

getClassMetaData() public method

Get this classes metadata object
public getClassMetaData ( ) : Drest\Mapping\ClassMetaData
return Drest\Mapping\ClassMetaData $class_metadata

getExpose() public method

Get the field exposure on this route
public getExpose ( ) : array
return array $expose

getHandleCall() public method

Get the handle call function
public getHandleCall ( ) : string
return string $handle_call

getName() public method

Get the name of this route
public getName ( ) : string
return string $name

getNamedRoute() public method

The unique named route to reference this route by Note that is should use the entities fully qualified class names
public getNamedRoute ( ) : string
return string

getOriginLocation() public method

Generate the location string from the provided object
public getOriginLocation ( object $object, string $url, EntityManager $em = null ) : string | false
$object object
$url string - the Url to be prepended to the location
$em Doctrine\ORM\EntityManager - Optionally pass the entity manager to assist in determining a GET origin location
return string | false

getRouteConditions() public method

Get the route conditions
public getRouteConditions ( ) : array | null
return array | null

getRouteParams() public method

Get any params that were set after a successful match
public getRouteParams ( ) : array
return array $params

getRoutePattern() public method

Get this routes route pattern
public getRoutePattern ( ) : string
return string $route_pattern

getVerbs() public method

Get an array of verbs that are allowed on this route
public getVerbs ( ) : array
return array

hasHandleCall() public method

Does this route have an annotated handle call
public hasHandleCall ( )

isAllowedOptionRequest() public method

Is this route allowed to expose its verbs to OPTIONS requests
public isAllowedOptionRequest ( ) : integer
return integer $result -1 if not set, 0 if no and 1 if yes

isCollection() public method

Should this route be handled as a collection
public isCollection ( )

isExposeDisabled() public method

Is the expose lookup disabled
public isExposeDisabled ( ) : boolean
return boolean

matches() public method

Does this request match the route pattern
public matches ( DrestCommon\Request\Request $request, boolean $matchVerb = true, string $basePath = null ) : boolean
$request DrestCommon\Request\Request
$matchVerb boolean - Whether you want to match the route using the request HTTP verb - useful for OPTIONS requests to provide route info
$basePath string - add a base path to the route pattern
return boolean $result

needsHandleCall() public method

Does this route need a handle call? Required for POST/PUT/PATCH verbs
public needsHandleCall ( ) : boolean
return boolean $response

serialize() public method

Serialise this object
public serialize ( ) : string
return string

setAllowedOptionRequest() public method

Set whether we would like to expose this route (and its verbs) to OPTIONS requests
public setAllowedOptionRequest ( integer | boolean $value = true )
$value integer | boolean - if using integer -1 to unset, 0 for no and 1 if yes

setClassMetaData() public method

Set this objects parent metadata class
public setClassMetaData ( Drest\Mapping\ClassMetaData $class_metadata )
$class_metadata Drest\Mapping\ClassMetaData

setCollection() public method

Whether requests to this route should be handled as collections
public setCollection ( boolean $value = true )
$value boolean

setDisableExpose() public method

Set disable expose flag
public setDisableExpose ( boolean $flag = true )
$flag boolean

setExpose() public method

An array of fields we're allowed to expose to the client
public setExpose ( array $expose )
$expose array

setHandleCall() public method

Set the handle function call
public setHandleCall ( string $handle_call )
$handle_call string

setName() public method

If other resources are created with this name an exception is thrown (must be unique)
public setName ( string $name )
$name string

setRouteConditions() public method

Add an array of route conditions
public setRouteConditions ( array $route_conditions )
$route_conditions array

setRouteParams() public method

Inject route params onto this object without performing a match. Useful when calling a named route directly
public setRouteParams ( array $params = [] )
$params array - should be an associative array. keyed values are ignored

setRoutePattern() public method

Add the route path. eg '/users/:id'
public setRoutePattern ( string $route_pattern )
$route_pattern string

setUnmappedRouteParams() public method

Useful when calling a named route directly
public setUnmappedRouteParams ( array $params = [] )
$params array - should be a keyed array. associative values are ignored

setVerbs() public method

Add verbs that are to be allowed on this route.
public setVerbs ( mixed $verbs )
$verbs mixed = a single or array of verbs valid for this route. eg array('GET', 'PUT')

unserialize() public method

Un-serialise this object and reestablish it's state
public unserialize ( string $string )
$string string

usesHttpVerbs() public method

Is this route specific to defined HTTP verbs
public usesHttpVerbs ( )

Property Details

$allowed_option_request protected_oe property

Whether this route is open to allow OPTION requests to detail available $verbs -1 = not set 0 = not allowed 1 = allowed
protected int $allowed_option_request
return integer

$class_metadata protected_oe property

This route objects parent
protected ClassMetaData,Drest\Mapping $class_metadata
return Drest\Mapping\ClassMetaData

$collection protected_oe property

Whether get requests to this route should be exposed / handled as collections
protected bool $collection
return boolean

$disable_expose protected_oe property

Prevent expose settings lookup
protected bool $disable_expose
return boolean

$expose protected_oe property

An array of fields to be exposed to the end client
protected array $expose
return array

$handle_call protected_oe property

A handle function call for this route (if one is configured)
protected string $handle_call
return string

$name protected_oe property

The route name (must be unique)
protected string $name
return string

$param_names protected_oe property

Key-value array of URL parameter names
protected array $param_names
return array

$param_names_path protected_oe property

Key-value array of URL parameters with + at the end
protected array $param_names_path
return array

$route_conditions protected_oe property

Eg array('year' => '(19|20)\d\d')
protected array $route_conditions
return array

$route_params protected_oe property

Key-value array of URL parameters populated after a match has been successful - or directly by using available setter
protected array $route_params
return array

$route_pattern protected_oe property

A string route pattern to be matched on. eg /user/:id
protected string $route_pattern
return string

$unmapped_route_params protected_oe property

The value id => 1 will go into $route_params All the rest will go in here.
protected array $unmapped_route_params
return array

$verbs protected_oe property

They match the constant values defined in DrestCommon\Request\Request eg array('GET', 'POST')
protected array $verbs
return array