Smalldb  v0.0-177-g1a83180
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Public Attributes | Protected Attributes | List of all members
RawApiBlock Class Reference

Raw and ugly connector to access Smalldb interface from outter world. More...

Inheritance diagram for RawApiBlock:
Inheritance graph

Public Member Functions

 main ()
 Block body.
 
- Public Member Functions inherited from BackendBlock
 __construct ($smalldb)
 Setup block to act as expected. More...
 

Public Attributes

const force_exec = true
 Block must be always executed.
 

Protected Attributes

 $inputs
 Block inputs. More...
 
 $outputs
 Block inputs. More...
 
- Protected Attributes inherited from BackendBlock
 $smalldb
 Smalldb backend obtained from block storage.
 

Detailed Description

Raw and ugly connector to access Smalldb interface from outter world.

Deprecated:
This connector will be replaced with something better soon.
Warning
This connector directly reads $_GET and $_POST, which is ugly. And to make it even worse, it produces output!

HTTP API

Following examples assume that this block is located at http://example.com/smalldb-api/ and input id is connected to router's path_tail, so any additional path in uRL is interpreted as entity ID.

Retrieving state machine state and properties

HTTP GET: http://example.com/smalldb-api/state/machine/id

State machine ID, state and properties are JSON encoded and sent back.

Browsing state machine space

HTTP GET: http://example.com/smalldb-api/?filter1=value1&filter2=value2&...

Entire $_GET is passed as an only argument to StateMachine::AbstractBackend::createListing().

Return value is JSON encoded and sent back.

Invoking a transition

HTTP POST: http://example.com/smalldb-api/state/machine/id
DATA: action, args_json

action is the action to be invoked, args_json contains JSON encoded list of arguments passed to StateMachine::Reference::__call().

Return value is JSON encoded and sent back.

Warning
json_args is array of arguments! It must be always an array.

Member Data Documentation

$inputs
protected
Initial value:
= array(
'id' => null,
)

Block inputs.

$outputs
protected
Initial value:
= array(
'result' => true,
'done' => true,
)

Block inputs.