libSmalldb
v0.7
|
Reference to one or more state machines.
Allows you to invoke transitions in the easy way by calling methods on this reference object. This is syntactic sugar only, nothing really happens here.
$id is per machine type unique identifier. It is always a single literal or an array of literals for compound primary keys.
Method call on this class invokes the transition.
Read-only properties:
Read one property (will load all of them): $ref['property']
Flush property cache: unset($ref->properties);
Public Member Functions | |
__construct (AbstractMachine $machine, $id=null) | |
Create reference and initialize it with given ID. More... | |
__debugInfo () | |
Show relevant data when using var_dump(). More... | |
jsonSerialize () | |
Support for json_encode() - implementation of JsonSerializable interface. More... | |
isNullRef () | |
Returns true if reference points only to machine type. More... | |
__call ($name, $arguments) | |
Function call is transition invocation. More... | |
__get ($key) | |
Get data from machine. More... | |
__unset ($key) | |
Flush cached data. More... | |
Static Public Member Functions | |
static | createPreheatedReference ($machine, $properties) |
Create pre-heated reference. More... | |
Protected Member Functions | |
clearCache () | |
Drop all cached data. More... | |
Protected Attributes | |
$machine | |
State machine. More... | |
$id | |
Primary key (unique within $machine). More... | |
$state_cache | |
Cached state of the machine. More... | |
$properties_cache | |
Cached properties of the machine. More... | |
$view_cache | |
Cached values from views on machine properties. More... | |
$persistent_view_cache = array() | |
Persistent view cache, which is not flushed automaticaly after every transition. More... | |
Hooks | |
Reference calls them when something interesting happens.
| |
afterPkChanged () | |
Hook invoked when reference primary key changes. More... | |
beforeTransition () | |
Hook invoked before transition is invoked. More... | |
afterTransition () | |
Hook invoked after transition is invoked. More... | |
Array access for properties | |
offsetExists ($offset) | |
offsetGet ($offset) | |
offsetSet ($offset, $value) | |
offsetUnset ($offset) | |
Iterator interface to iterate over properties | |
rewind () | |
current () | |
key () | |
next () | |
valid () | |
__construct | ( | AbstractMachine | $machine, |
$id = null |
|||
) |
Create reference and initialize it with given ID.
To copy a reference use clone keyword.
afterPkChanged | ( | ) |
Hook invoked when reference primary key changes.
Callback: function($ref, $new_pk)
beforeTransition | ( | ) |
Hook invoked before transition is invoked.
Callback: function($ref, $transition_name, $arguments)
afterTransition | ( | ) |
Hook invoked after transition is invoked.
Callback: function($ref, $transition_name, $arguments, $return_value, $returns)
__debugInfo | ( | ) |
Show relevant data when using var_dump().
jsonSerialize | ( | ) |
Support for json_encode() - implementation of JsonSerializable interface.
|
static |
Create pre-heated reference.
isNullRef | ( | ) |
Returns true if reference points only to machine type.
Such reference may not be used to modify any machine, however, it can be used to invoke 'create'-like transitions.
|
protected |
Drop all cached data.
__call | ( | $name, | |
$arguments | |||
) |
Function call is transition invocation.
Just forward it to backend.
When transition returns new ID, the reference is updated to keep it pointing to the same state machine.
__get | ( | $key | ) |
Get data from machine.
If you want to retrieve both state and properties, ask for properties first. The state may get pre-cached.
__unset | ( | $key | ) |
Flush cached data.
|
protected |
State machine.
|
protected |
Primary key (unique within $machine).
|
protected |
Cached state of the machine.
|
protected |
Cached properties of the machine.
|
protected |
Cached values from views on machine properties.
|
protected |
Persistent view cache, which is not flushed automaticaly after every transition.