libSmalldb  v0.7-66-gb94d22a
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ArrayMachine Class Reference

Description

Simple testing machine implementation.

Uses array to store all data. Any transition is allowed.

Inheritance diagram for ArrayMachine

Public Member Functions

 describeId ()
 Reflection: Describe ID (primary key). More...
 
 getState ($id)
 Get current state of state machine. More...
 
 getProperties ($id, & $state_cache=null)
 Get all properties_storage of state machine, including it's state. More...
 
 __call ($method, $args)
 Fake method for all transitions. More...
 
- Public Member Functions inherited from AbstractMachine
 __construct ()
 Constructor is left empty so the machine implementation can use it to obtain resources automatically via dependency injection. More...
 
 initializeMachine (Smalldb $smalldb, string $type, array $config)
 Configure machine. More...
 
 getReferenceClassName ()
 
 setDebugLogger (IDebugLogger $debug_logger)
 Set debug logger. More...
 
 getDebugLogger ()
 Get debug logger. More...
 
 getErrors ()
 Get errors found while loading the machine definition. More...
 
 getState ($id)
 Get current state of state machine. More...
 
 getProperties ($id, & $state_cache=null)
 Get properties of state machine, including it's state. More...
 
 getView ($id, $view, & $properties_cache=null, & $view_cache=null, & $persistent_view_cache=null)
 Get properties in given view. More...
 
 isTransitionAllowed (Reference $ref, $transition_name, $state=null, & $access_policy=null)
 Returns true if transition can be invoked right now. More...
 
 getAvailableTransitions (Reference $ref, $state=null)
 Get list of all available actions for state machine instance identified by $id. More...
 
 invokeTransition (Reference $ref, $transition_name, $args, & $returns, callable $new_id_callback=null)
 Invoke state machine transition. More...
 
 getMachineType ()
 Get type of this machine. More...
 
 ref ($id)
 Helper to create Reference to this machine. More...
 
 nullRef ()
 Helper to create null Reference to this machine. More...
 
 hotRef ($properties)
 Create pre-heated reference using properties loaded from elsewhere. More...
 
 performSelfCheck ()
 Perform self-check. More...
 
 findUnreachableStates ()
 Run DFS from not-exists state and return list of unreachable states. More...
 
 describeId ()
 Reflection: Describe ID (primary key). More...
 
 getUrlFormat ()
 Get URL format. More...
 
 getParentUrlFormat ()
 Get prent URL format. More...
 
 getPostActionUrlFormat ()
 Get URL for redirect-after-post. More...
 
 getMachineImplementationMTime ()
 Get mtime of machine implementation. More...
 
 getAllMachineStates ($having_section=null)
 Reflection: Get all states. More...
 
 describeMachineState ($state, $field=null)
 Reflection: Describe given machine state. More...
 
 describeAllMachineStates ($having_section=null)
 Reflection: Describe all states. More...
 
 getAllMachineActions ($having_section=null)
 Reflection: Get all actions (transitions) More...
 
 describeMachineAction ($action, $field=null)
 Reflection: Describe given machine action (transition) More...
 
 describeAllMachineActions ($having_section=null)
 Reflection: Describe all actions (transitions) More...
 
 getAllMachineProperties ($having_section=null)
 Reflection: Get all properties. More...
 
 describeMachineProperty ($property, $field=null)
 Reflection: Describe given property. More...
 
 describeAllMachineProperties ($having_section=null)
 Reflection: Describe all properties. More...
 
 getAllMachineViews ($having_section=null)
 Reflection: Get all views. More...
 
 describeMachineView ($view, $field=null)
 Reflection: Describe given view. More...
 
 describeAllMachineViews ($having_section=null)
 Reflection: Describe all views. More...
 
 getAllMachineReferences ($having_section=null)
 Reflection: Get all references. More...
 
 describeMachineReference ($reference, $field=null)
 Reflection: Describe given reference. More...
 
 describeAllMachineReferences ($having_section=null)
 Reflection: Describe all references. More...
 
 exportJson ($debug_opts=false)
 Export state machine as JSON siutable for Grafovatko. More...
 
 exportDot ($debug_opts=false)
 Export state machine to Graphviz source code. More...
 

Protected Member Functions

 checkAccessPolicy ($access_policy, Reference $ref)
 Returns true if user has required access_policy to invoke a transition, which requires given access_policy. More...
 
 addPermissionsCondition ($query)
 Adds conditions to enforce read permissions to query object. More...
 
- Protected Member Functions inherited from AbstractMachine
 configureMachine (array $config)
 Define state machine used by all instances of this type. More...
 
 setupDefaultMachine (array $config)
 Setup default machine when initializeMachine is finished. More...
 
 loadMachineConfig (array $config, array $keys)
 Merge $config into state machine member variables (helper method). More...
 
 checkAccessPolicy ($access_policy, Reference $ref)
 Returns true if user has required access_policy to invoke a transition, which requires given access_policy. More...
 
 calculateViewValue ($id, $view, & $properties_cache=null, & $view_cache=null, & $persistent_view_cache=null)
 Calculate value of a view. More...
 
 urlFormat ($id, $url_fmt, $properties_cache)
 Create URL using properties and given format. More...
 
 resolveMachineReference (string $reference_name, array $properties_cache)
 Helper function to resolve reference to another machine. More...
 
 onStateChanged (Reference $ref, $old_state, $transition_name, $new_state)
 Called when state is changed, when transition invocation is completed. More...
 
 exportDotRenderExtras ($debug_opts)
 Render extra diagram features. More...
 
 exportJsonAddExtras ($debug_opts, array $machine_graph)
 Add extra diagram features into the diagram. More...
 

Protected Attributes

 $properties_storage = array()
 Data storage for all state machines. More...
 
- Protected Attributes inherited from AbstractMachine
 $smalldb = null
 Smalldb entry point More...
 
 $machine_type
 Identification of the machine. More...
 
 $reference_class = null
 Class name of the Reference class. More...
 
 $state_diagram_extras = []
 List of additional diagram parts in Dot language provided by backend (and its readers). More...
 
 $state_diagram_extras_json = []
 
 $errors = []
 List of errors in state machine definition. More...
 
 $url_fmt
 URL format string where machine is located, usualy only the path part, e.g. More...
 
 $parent_url_fmt
 URL format string where parent of this machine is located, usualy only the path part, e.g. More...
 
 $post_action_url_fmt
 URL format string for redirect-after-post. More...
 
 $states
 Descriptions of all known states – key is state id, value is * description. More...
 
 $state_groups
 State groups. More...
 
 $actions
 Description of all known actions – key is action name. More...
 
 $default_access_policy = null
 Default access policy. More...
 
 $read_access_policy = null
 Read access policy. More...
 
 $listing_access_policy = null
 Listing access policy. More...
 
 $access_policies
 Access policies. More...
 
 $properties
 Description of machine properties – key is property name. More...
 
 $views
 Description of machine views – key is view name. More...
 
 $references
 Description of machine references. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from AbstractMachine
static exportDotIdentifier (string $str, string $prefix='s_')
 Convert state machine state name or group name to a safe dot identifier. More...
 
- Public Attributes inherited from AbstractMachine
const RETURNS_VALUE = null
 Return value of invoked transition is just some value. More...
 
const RETURNS_NEW_ID = 'new_id'
 Return value of invoked transition is new ID of the state machine. More...
 

Member Function Documentation

◆ describeId()

describeId ( )

Reflection: Describe ID (primary key).

◆ checkAccessPolicy()

checkAccessPolicy (   $access_policy,
Reference  $ref 
)
protected

Returns true if user has required access_policy to invoke a transition, which requires given access_policy.

◆ addPermissionsCondition()

addPermissionsCondition (   $query)
protected

Adds conditions to enforce read permissions to query object.

◆ getState()

getState (   $id)

Get current state of state machine.

◆ getProperties()

getProperties (   $id,
$state_cache = null 
)

Get all properties_storage of state machine, including it's state.

◆ __call()

__call (   $method,
  $args 
)

Fake method for all transitions.

Member Data Documentation

◆ $properties_storage

$properties_storage = array()
protected

Data storage for all state machines.