PHP code example of raoul2000 / yii-simple-workflow

1. Go to this page and download the library: Download raoul2000/yii-simple-workflow library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

raoul2000 / yii-simple-workflow example snippets


'components'=>array(	
	// adding the simple Workflow source component
	'swSource'=> array(
		'class'=>'application.extensions.simpleWorkflow.SWPhpWorkflowSource',
	), ...


'import'=>array(
	...
	'application.extensions.simpleWorkflow.*',	// Import simpleWorkflow extension
), 

class MyModel extends CActiveRecord {
	public function behaviors()
	{
		return array(
			'swBehavior' => array(
				'class' => 'application.extensions.simpleWorkflow.SWActiveRecordBehavior'
			)
		);
	}
}

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