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

Base class for state machines accessed via Flupdo. More...

Inheritance diagram for FlupdoMachine:
Inheritance graph

Public Member Functions

 createListing ($filters)
 Create generic listing on this machine type. More...
 
 createQueryBuilder ()
 Create query builder.
 
 getState ($id)
 Get current state of state machine.
 
 getProperties ($id, &$state_cache=null)
 Get all properties of state machine, including it's state.
 
 encodeProperties ($properties)
 Encode properties to database representation. More...
 
 decodeProperties ($properties)
 Decode properties from database representation. More...
 
 describeId ()
 Reflection: Describe ID (primary key). More...
 
- Public Member Functions inherited from AbstractMachine
 __construct (AbstractBackend $backend, $type, $config, $context)
 Constructor. 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 ($id, $transition_name, $state=null)
 Returns true if transition can be invoked right now. More...
 
 getAvailableTransitions ($id, $state=null)
 Get list of all available actions for state machine instance identified by $id.
 
 invokeTransition ($id, $transition_name, $args, &$returns)
 Invoke state machine transition. More...
 
 flushCache ()
 If machine properties are cached, flush all cached data.
 
 getMachineType ()
 Get type of this machine.
 
 getBackend ()
 Get backend which owns this machine.
 
 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.
 
 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)
 
 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.
 
 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.
 
 exportDot ()
 Export state machine to Graphviz source code.
 

Protected Member Functions

 initializeMachine ($config)
 Define state machine used by all instances of this type.
 
 scanTableColumns ()
 Scan table in database and populate properties and pk_columns arrays. More...
 
 checkAccessPolicy ($access_policy_name, $id)
 Returns true if user has required access_policy. More...
 
 addAccessPolicyCondition ($query)
 Adds conditions to enforce read access_policy to query object. More...
 
 queryAddFrom ($query)
 Add FROM clause.
 
 queryAddStateSelect ($query)
 Add state column into select clause of the $query. More...
 
 queryAddPropertiesSelect ($query)
 Add properties to select. More...
 
 queryAddPrimaryKeyWhere ($query, $id)
 Add primary key condition to where clause. More...
 
- Protected Member Functions inherited from AbstractMachine
 initializeMachine ($config)
 Define state machine used by all instances of this type.
 
 checkAccessPolicy ($access_policy, $id)
 Returns true if user has required access_policy to invoke a transition, which requires given access_policy.
 
 resolveMachineReference ($reference_name, $properties_cache, &$ref_machine_type, &$ref_machine_id)
 Helper function to resolve reference to another machine. More...
 
 onStateChanged ($id, $old_state, $transition_name, $new_state)
 Called when state is changed, when transition invocation is completed.
 

Protected Attributes

 $flupdo
 Database connection.
 
 $table
 Name of SQL table, where machine properties are stored.
 
 $pk_columns = null
 List of columns which are used as primary key.
 
 $json_columns = array()
 List of columns which are serialized as JSON in database.
 
 $user_id_table_column = null
 Column containing entity owner.
 
 $user_id_auth_method = null
 Auth object method name to retrieve current user ID. More...
 
 $load_state_with_properties = true
 True if state should not be loaded with properties.
 
 $filters = null
 Filters defined in configuration.
 
 $default_filters = null
 Default filters for listing.
 
 $state_select = null
 Select expression for selecting machine state.
 
- Protected Attributes inherited from AbstractMachine
 $backend
 Backend, where all machines are stored.
 
 $context
 Global context passed from backend.
 
 $machine_type
 Identification within $backend.
 
 $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...
 
 $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

- Public Attributes inherited from AbstractMachine
const RETURNS_VALUE = null
 Return value of invoked transition is just some value.
 
const RETURNS_NEW_ID = 'new_id'
 Return value of invoked transition is new ID of the state machine.
 

Detailed Description

Base class for state machines accessed via Flupdo.

Most of its protected member properties can be set via config options injected during initialization.

Member Function Documentation

scanTableColumns ( )
protected

Scan table in database and populate properties and pk_columns arrays.

Todo:
Do not include corrupted information, but at least something.

Here is the caller graph for this function:

checkAccessPolicy (   $access_policy_name,
  $id 
)
protected

Returns true if user has required access_policy.

/

Todo:
Caching ? Reference object has property cache. It would be nice to pass it here.
Todo:
Remove hardcoded role name

Here is the call graph for this function:

addAccessPolicyCondition (   $query)
protected

Adds conditions to enforce read access_policy to query object.

Todo:

Here is the caller graph for this function:

createListing (   $filters)

Create generic listing on this machine type.

See also
FlupdoGenericListing

Here is the call graph for this function:

queryAddStateSelect (   $query)
protected

Add state column into select clause of the $query.

Must add only one column.

Here is the caller graph for this function:

queryAddPropertiesSelect (   $query)
protected

Add properties to select.

/

Todo:
Skip some properties in lisings.

Here is the caller graph for this function:

queryAddPrimaryKeyWhere (   $query,
  $id 
)
protected

Add primary key condition to where clause.

Result should contain only one row now.

Returns $query.

Here is the call graph for this function:

Here is the caller graph for this function:

encodeProperties (   $properties)

Encode properties to database representation.

NULL values are preserved.

You should not need to call this, it is called automaticaly at the right time.

Here is the caller graph for this function:

decodeProperties (   $properties)

Decode properties from database representation.

NULL values are preserved.

You should not need to call this, it is called automaticaly at the right time.

Here is the caller graph for this function:

describeId ( )

Reflection: Describe ID (primary key).

Returns array of all parts of the primary key and its types (as strings). If primary key is not compound, something like array('id') is returned.

Order of the parts may be mandatory.

Here is the caller graph for this function:

Member Data Documentation

$user_id_auth_method = null
protected

Auth object method name to retrieve current user ID.

/

Todo:
Review this.