simpleWorkflow
  • Class
  • Tree

Classes

  • SWActiveRecord
  • SWActiveRecordBehavior
  • SWComponent
  • SWEvent
  • SWException
  • SWHelper
  • SWNode
  • SWPhpWorkflowSource
  • SWValidator
  • SWWorkflowSource
  • SWyEdConverter
  • SWyEdConverterDOM

simpleWorkflow

Classes summary

SWActiveRecord This is the base class for all AR models that needs to handle events fired by the simpleWorkflow behavior. Handling simpleWorkflow events can also be achieved by creating a behavior that inherits from SWActiveRecordBehavior and overload default event handlers
SWActiveRecordBehavior This class implements all the logic for the simpleWorkflow extension. Following attributes can be initialized when this behavior is attached to the owner component :
  • statusAttribute (string) : This is the column name where status is stored
    If this attribute doesn't exist for a model, the Workflow behavior is automatically disabled and a warning is logged.
    In the database, this attribute must be defined as a VARCHAR() whose length should be large enough to contains a complete status name with format workflowId/nodeId.
    example : <pre> task/pending postWorkflow/to_review </pre> Default : 'status'
  • defaultWorkflow (string) : workflow name that should be used by default for the owner model
    If this parameter is not set, then it is automatically created based on the name of the owner model, prefixed with 'workflowNamePrefix' defined by the workflow source component. By default this value is set to 'sw' and so, for example 'Model1' is associated by default with workflow 'swModel1'.
    Default : SWWorkflowSource->workflowNamePrefix . ModelName
  • autoInsert (boolean) :
    If TRUE, the model is automatically inserted in the workflow (if not already done) when it is saved. If FALSE, it is developer responsability to insert the model in the workflow.
    Default : true
  • workflowSourceComponent (string) :
    Name of the workflow source component to use with this behavior.
    By ddefault this parameter is set to <em>swSource</em> (see SWPhpWorkflowSource)
  • enableEvent (boolean) :
    If TRUE, this behavior will fire SWEvents. Note that even if it is true, this doesn't garantee that SW events will be fired as another condition is that the owner component provides SWEvent handlers.
    Default : true
  • transitionBeforeSave (boolean) :
    If TRUE, SWEvents are fired and possible transitions tasks are executed before the owner model is actually saved. If FALSE, events and task transitions are processed after save.
    It has no effect if the transition is done programatically by a call to swNextStatus(), but only if it is done when the owner model is saved.
    Default : true
SWComponent This is the base class for all components that needs to handle events fired by the simpleWorkflow behavior. Note that in most cases, this class is not used as the sW behavior is usually attached to a CActiveRecord object.
SWEvent this class implements events fired by the simpleWorkflow behavior. This event is fired at different time during a transition (see (see SWActiveRecordBehavior::events()).
SWException Exception thrown by the simpleWorkflow behavior.
SWHelper this class provides helper methods for the simpleWorkflow behavior
SWNode This class implements a graph node for the simpleWorkflow extension.
SWPhpWorkflowSource This class gives access to workflow and statuses stored as PHP files. Following attributes can be initialized when the component is configured:
  • basePath (string) : the base path alias where all workflow are stored.By default, it is set to application.models.workflows (folder "protected/models/workflows").
  • definitionType (string) : Defines the type of PHP file to load. A Workflow can be defined in a PHP file that contains a simple array definition (definitionType = 'array'), or by a class (definitionType = 'class'). By default this attribute is set to 'array'.
SWValidator

This validator should be used to validate the 'status' attribute for an active record object before it is saved. It tests if the transition that is about to occur is valid.
Moreover, if <strong>$enableSwValidation</strong> is set to true, this validator applies all validators that may have been defined by the model for the scenario associated to the transition being done.
Scenario names associated with a transition, have the following format : <pre> sw-[nextStatus] </pre> For instance, if the model being validated is currently in status 'A' and it is sent in status 'B', the corresponding scenario name is 'sw:A-B'. Note that if the destination status doesn't belong to the same workflow as the current status, [nextStatus] must be in the form 'workflowId/statusId' (e.g 'sw:A-workflow/B'). Eventually, when the model enters in a workflow, the scenario name is '-[nextStatus]' where 'nextStatus' includes the workflow Id (e.g 'sw:-workflowIs/statusId').

If this validator is initialized with parameter match set to TRUE, then transitions scenario defined for validators are assumed to be regular expressions. If the current transition matches, then the associated validator is executed.
For instance, if validator 'required' for attribute A applies to scenarion 'sw:/S1_.?/' then each time the model leaves status S1, then the <em>required</em> validator will be applied.

SWWorkflowSource This is the base class for all workflow source implementations. It provides basic initialization features and a set of methods that must be implemented by workflow source classes.
SWyEdConverter Converts a workflow created with yEd Graph Editor (freeware) and saved in graphml format into an array suitable to be used with the simpleWorkflow extension (sW).
The conversion is based on the $mapper array, which defines matches between sW attributes and properties used by yEd. Following sW values are references using a predefined name :
  • workflow - initial : is the id of the initial node
  • node - id : id of a given node
  • node - constraint : PHP expression used as constraint for a node
  • node - label : text label for a node
  • node - metadata.* : custom metadata value
  • edge - task : PHP expression executed when the transition is performed
yEd Graph Editor node attributes are referenced in two ways : by their attribute name or by an xpath expression that applies to the y:ShapeNode element used by yEd to draw each node. The later is mainly usefule to extract the node label and possibly, some other informations like for instance the background color or text color used to render each node. The former is useful to extract built-in yEd attribute and also custom attribute defined by the user.
SWyEdConverterDOM Converts a workflow created with yEd Graph Editor (freeware) and saved in graphml format into an array suitable to be used with the simpleWorkflow extension (sW).
The conversion is based on the $mapper array, which defines matches between sW attributes and properties used by yEd. Following sW values are references using a predefined name :
  • workflow - initial : is the id of the initial node
  • node - id : id of a given node
  • node - constraint : PHP expression used as constraint for a node
  • node - label : text label for a node
  • node - metadata.* : custom metadata value
  • edge - task : PHP expression executed when the transition is performed
yEd Graph Editor node attributes are referenced in two ways : by their attribute name or by an xpath expression that applies to the y:ShapeNode element used by yEd to draw each node. The later is mainly usefule to extract the node label and possibly, some other informations like for instance the background color or text color used to render each node. The former is useful to extract built-in yEd attribute and also custom attribute defined by the user.
simpleWorkflow API documentation generated by ApiGen 2.8.0