PHP Class RESTfulAPI_DefaultQueryHandler

..
Author: Thierry Francois @colymba [email protected]
Inheritance: implements RESTfulAPI_QueryHandler
ファイルを表示 Open project: colymba/silverstripe-restfulapi

Public Properties

Property Type Description
$deSerializer RESTfulAPI_DeSerializer Current deSerializer instance
$requestedData array Stores the currently requested data

Public Methods

Method Description
createModel ( string $model, SS_HTTPRequest $request ) : DataObject Create object of class $model
deleteModel ( string $model, integer $id, SS_HTTPRequest $request ) : null | array Delete object of Class $model and ID $id
findModel ( string $model, boolean | integr $id = false, array $queryParams, SS_HTTPRequest $request ) : DataObject | DataList Finds 1 or more objects of class $model
getdeSerializer ( ) : RESTfulAPI_DeSerializer Return current RESTfulAPI DeSerializer instance
handleQuery ( SS_HTTPRequest $request ) : DataObjec | DataList All requests pass through here and are redirected depending on HTTP verb and params
parseQueryParameters ( array $params ) : array Parse the query parameters to appropriate Column, Value, Search Filter Modifiers array( array( 'Column' => ColumnName, 'Value' => ColumnValue, 'Modifier' => ModifierType ) )
updateModel ( String | DataObject $model, integer $id, $request ) : DataObject Update databse record or $model

Method Details

createModel() public method

Create object of class $model
public createModel ( string $model, SS_HTTPRequest $request ) : DataObject
$model string
$request SS_HTTPRequest
return DataObject

deleteModel() public method

Delete object of Class $model and ID $id
public deleteModel ( string $model, integer $id, SS_HTTPRequest $request ) : null | array
$model string Model class
$id integer Model ID
$request SS_HTTPRequest Model ID
return null | array NULL if successful or array with error detail

findModel() public method

Handles column modifiers: :StartsWith, :EndsWith, :PartialMatch, :GreaterThan, :LessThan, :Negation and query modifiers: sort, rand, limit
public findModel ( string $model, boolean | integr $id = false, array $queryParams, SS_HTTPRequest $request ) : DataObject | DataList
$model string Model(s) class to find
$id boolean | integr The ID of the model to find or false
$queryParams array Query parameters and modifiers
$request SS_HTTPRequest The original HTTP request
return DataObject | DataList Result of the search (note: DataList can be empty)

getdeSerializer() public method

Return current RESTfulAPI DeSerializer instance
public getdeSerializer ( ) : RESTfulAPI_DeSerializer
return RESTfulAPI_DeSerializer DeSerializer instance

handleQuery() public method

All requests pass through here and are redirected depending on HTTP verb and params
public handleQuery ( SS_HTTPRequest $request ) : DataObjec | DataList
$request SS_HTTPRequest HTTP request
return DataObjec | DataList DataObject/DataList result or stdClass on error

parseQueryParameters() public method

Parse the query parameters to appropriate Column, Value, Search Filter Modifiers array( array( 'Column' => ColumnName, 'Value' => ColumnValue, 'Modifier' => ModifierType ) )
public parseQueryParameters ( array $params ) : array
$params array raw GET vars array
return array formatted query parameters

updateModel() public method

Update databse record or $model
public updateModel ( String | DataObject $model, integer $id, $request ) : DataObject
$model String | DataObject the model or class to update
$id integer The ID of the model to update
return DataObject The updated model

Property Details

$deSerializer public_oe property

Current deSerializer instance
public RESTfulAPI_DeSerializer $deSerializer
return RESTfulAPI_DeSerializer

$requestedData public_oe property

Stores the currently requested data
public array $requestedData
return array