Detailed Description

RESTController handles requests sent from a dstore/Rest client.

See also
http://dstorejs.io

The controller supports the following actions:

Action default
Handle action according to HTTP method and parameters.
For details about the parameters, see documentation of the methods.
Response Actions
ok In all cases
Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 51 of file RESTController.php.

+ Inheritance diagram for RESTController:

Public Member Functions

 __construct (Session $session, PersistenceFacade $persistenceFacade, PermissionManager $permissionManager, ActionMapper $actionMapper, Localization $localization, Message $message, Configuration $configuration, EventManager $eventManager)
 
 __destruct ()
 
 initialize (Request $request, Response $response)
 
 read ()
 
 readList ()
 
 readInRelation ()
 
 create ()
 
 createInRelation ()
 
 update ()
 
 updateInRelation ()
 
 delete ()
 
 deleteInRelation ()
 
 afterCommit (TransactionEvent $event)
 
- Public Member Functions inherited from Controller
 __construct (Session $session, PersistenceFacade $persistenceFacade, PermissionManager $permissionManager, ActionMapper $actionMapper, Localization $localization, Message $message, Configuration $configuration)
 
 execute ($method=null)
 
 getRequest ()
 
 getResponse ()
 

Protected Member Functions

 validate ()
 
 handleSubResponse (Response $subResponse, $oidStr=null)
 
 setLocationHeaderFromOid ($oidStr)
 
 getFirstRequestOid ()
 
 getRelatedType (ObjectId $sourceOid, $role)
 
- Protected Member Functions inherited from Controller
 doExecute ($method=null)
 
 executeSubAction ($action)
 
 redirect ($location, $key=null, $data=null)
 
 getLogger ()
 
 getSession ()
 
 getPersistenceFacade ()
 
 getPermissionManager ()
 
 getActionMapper ()
 
 getLocalization ()
 
 getMessage ()
 
 getConfiguration ()
 
 requireTransaction ()
 
 endTransaction ($commit)
 
 isLocalizedRequest ()
 
 checkLanguageParameter ()
 
 generateCsrfToken ($name, $refresh=true)
 
 validateCsrfToken ($name, $invalidate=true)
 
 getLocalSessionValue ($key, $default=null)
 
 setLocalSessionValue ($key, $value)
 
 clearLocalSessionValues ()
 

Additional Inherited Members

- Public Attributes inherited from Controller
const CSRF_TOKEN_PARAM = 'csrf_token'
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( Session  $session,
PersistenceFacade  $persistenceFacade,
PermissionManager  $permissionManager,
ActionMapper  $actionMapper,
Localization  $localization,
Message  $message,
Configuration  $configuration,
EventManager  $eventManager 
)

Constructor.

Parameters
$session
$persistenceFacade
$permissionManager
$actionMapper
$localization
$message
$configuration
$eventManager

Definition at line 67 of file RESTController.php.

◆ __destruct()

__destruct ( )

Destructor.

Definition at line 85 of file RESTController.php.

Member Function Documentation

◆ initialize()

initialize ( Request  $request,
Response  $response 
)
See also
Controller::initialize()

Reimplemented from Controller.

Definition at line 92 of file RESTController.php.

◆ validate()

validate ( )
protected
See also
Controller::validate()

Reimplemented from Controller.

Definition at line 118 of file RESTController.php.

◆ read()

read ( )

Read an object.

Parameter Description
in language The language of the returned object
in className The type of returned object
in id The id of returned object
out Single object

Definition at line 150 of file RESTController.php.

◆ readList()

readList ( )

Read objects of a given type.

Parameter Description
in language The language of the returned objects
in className The type of returned objects
in sortBy ?sortBy=+foo for sorting the list by foo ascending or
in sort ?sort(+foo) for sorting the list by foo ascending
in limit ?limit(10,25) for loading 10 objects starting from position 25
in query A query condition encoded in RQL to be used with StringQuery::setRQLConditionString()
out List of objects

Definition at line 169 of file RESTController.php.

◆ readInRelation()

readInRelation ( )

Read objects that are related to another object.

Parameter Description
in language The language of the returned objects
in sourceId Id of the object to which the returned objects are related (determines the object id together with className)
in className The type of the object defined by sourceId
in relation Name of the relation to the object defined by sourceId (determines the type of the returned objects)
in sortBy ?sortBy=+foo for sorting the list by foo ascending or
in sort ?sort(+foo) for sorting the list by foo ascending
in limit ?limit(10,25) for loading 10 objects starting from position 25
in query A query condition encoded in RQL to be used with StringQuery::setRQLConditionString()
out List of objects

Definition at line 190 of file RESTController.php.

◆ create()

create ( )

Create an object of a given type.

Parameter Description
in language The language of the object
in className Type of object to create
out Created object data

The object data is contained in POST content.

Definition at line 238 of file RESTController.php.

◆ createInRelation()

createInRelation ( )

Create an object of a given type in the given relation.

Parameter Description
in language The language of the object
in className Type of object to create
in sourceId Id of the object to which the created objects are added (determines the object id together with className)
in relation Name of the relation to the object defined by sourceId (determines the type of the created/added object)
out Created object data

The object data is contained in POST content. If an existing object should be added, an oid parameter in the object data is sufficient.

Definition at line 267 of file RESTController.php.

◆ update()

update ( )

Update an object or change the order.

Parameter Description
in language The language of the object
in className Type of object to update
in id Id of object to update
out Updated object data

The object data is contained in POST content.

Definition at line 318 of file RESTController.php.

◆ updateInRelation()

updateInRelation ( )

Update an object in a relation or change the order.

Parameter Description
in language The language of the object
in className Type of object to update
in id Id of object to update
in relation Relation name if an existing object should be added to a relation (determines the type of the added object)
in sourceId Id of the object to which the added object is related (determines the object id together with className)
in targetId Id of the object to be added to the relation (determines the object id together with relation)
out Updated object data

The object data is contained in POST content.

Definition at line 367 of file RESTController.php.

◆ delete()

delete ( )

Delete an object.

Parameter Description
in language The language of the object
in className Type of object to delete
in id Id of object to delete

Definition at line 420 of file RESTController.php.

◆ deleteInRelation()

deleteInRelation ( )

Remove an object from a relation.

Parameter Description
in language The language of the object
in className Type of object to delete
in id Id of object to delete
in relation Name of the relation to the object defined by sourceId (determines the type of the deleted object)
in sourceId Id of the object to which the deleted object is related (determines the object id together with className)
in targetId Id of the object to be deleted from the relation (determines the object id together with relation)

Definition at line 444 of file RESTController.php.

◆ handleSubResponse()

handleSubResponse ( Response  $subResponse,
  $oidStr = null 
)
protected

Create the actual response from the response resulting from delegating to another controller.

Parameters
$subResponseThe response returned from the other controller
$oidStrSerialized object id of the object to return (optional)
Returns
Boolean whether an error occured or not

Definition at line 468 of file RESTController.php.

◆ afterCommit()

afterCommit ( TransactionEvent  $event)

Update oids after commit.

Parameters
$event

Definition at line 504 of file RESTController.php.

◆ setLocationHeaderFromOid()

setLocationHeaderFromOid (   $oidStr)
protected

Set the location response header according to the given object id.

Parameters
$oidStrThe serialized object id

Definition at line 528 of file RESTController.php.

◆ getFirstRequestOid()

getFirstRequestOid ( )
protected

Get the first oid from the request.

Returns
String

Definition at line 540 of file RESTController.php.

◆ getRelatedType()

getRelatedType ( ObjectId  $sourceOid,
  $role 
)
protected

Get the type that is used in the given role related to the given source object.

Parameters
$sourceOidObjectId of the source object
$roleThe role name
Returns
String

Definition at line 557 of file RESTController.php.