simpleworkflow A simple workflow engine for active records

  1. Documentation
  2. Change Log

simpleWorkflow

The simpleWorkflow extension is a set of Yii components that is dedicated to provide an easy way to manage the life cycle of CActiveRecord objects inside a workflow. It provides features to control the behavior of the active record in its associated workflow : transition tasks, status constraints, event model.

Workflows are defined as associative arrays or as classes. They can be created manually, but for your convenience, since version 1.1, a Gii command is provided to automatically convert any workflow created by the yEd Graphical Editor into a simpleWorkflow : check out the video to learn more about it.

Please note that the simpleWorkflow command for Gii is still experimental

Resources

Documentation

Requirements
  • Yii 1.1.4 or above
  • the Gii command requires domxml PHP extension and since version 1.1.0.8, the DOM extension is also supported
Installation
  • Extract the release file under protected/extensions
  • add the SWPhpWorkflowSource component to your configuration
'components'=>array(	
	// adding the simple Workflow source component
	'swSource'=> array(
		'class'=>'application.extensions.simpleWorkflow.SWPhpWorkflowSource',
	), ...
  • add simpleWorkflow extension base folder to your imports
'import'=>array(
	...
        // Import simpleWorkflow components : validator, helper ...      
	'application.extensions.simpleWorkflow.*',	
), 

For more information on how to use the simpleWorkflow extension, please refer to the documentation

Usage

Once installed and correctly configured, the simpleWorkflow extension will handle the workflow for any model. This happens automatically when the model is read/saved from/to database, or programatically by the developer. For instance :

$m=MyModel::model()->findByPk('1');
if( $m->swHasStatus() ){
     echo 'status : '.$m->swGetStatus()->toString();		
}else {
     $m->swInsertToWorkflow();
     $m->save();
}

Change Log

May 26, 2013
  • version 1.1.0.8
    • gii command : add SWyEdConverterDOM that uses DOM extension. If domxml extension is available, use it in priority otherwise use DOM
    • add swSetStatus() to replace swNextStatus() which is still supported, but deprecated
September 19, 2012
  • version 1.1
    • change swNextStatus() : it is not permitted anymore to call 'swNextStatus()' with no argument. To insert a model into a workflow, swNextStatus() must be replaced by a call to 'swInsertToWorkflow()'.
    • enh : add method 'swRemoveFromWorkflow()'. This method is only successful when the owner model is in a final status (i.e a status with no outgoing transition).
    • enh : add swGetWorkflowSource() as public method to return the workflow source component used by the behavior
    • Gii command to convert yEd Graph Editor workflows into sW workflows (experimental)
    • enh : when loading a workflow, raise exception on duplicate node id
August 15, 2012
  • Version 1.0
    • fix : autoinsert into workflow (jmariani)
    • enh : replace function is_a() by instanceof (kjharni)
    • enh : metadata. It is now possible to add any value to node definition by using the metadata attribute.
    • enh : workflow class definition. A workflow can be defined as a class that must implement method getDefinition() which returns the workflow definition in its array format.
    • enh : add 'leaveWorkflow' event. This event is fired whenever a component in a workflow reset its status. This must be done from a final status only.
November 27, 2010
  • (RC2)
    • fix : replace 'split' with 'explode' (got 2 doodle)
    • enh : SWActiveRecordBehavior->swValidate now returns boolean
    • enh : Workflow Driven Model Validation. It is now possible to define validators which are only executed upon specific transitions (this is done by defining specific scenario names).
October 3, 2010
  • Initial release (RC1).
24 0
46 followers
5 035 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Others
Developed by: Raoul
Created on: Oct 3, 2010
Last updated: 11 years ago

Downloads

show all

Related Extensions