This class implements all the logic for the simpleWorkflow extension. It must be attached to an object that inherits from the CActiveRecord class. It can be initialized with following parameters :
Definition at line 32 of file SWActiveRecordBehavior.php.
| afterFind | ( | $ | event | ) |
Responds to CActiveRecord::onAfterFind event. This method is called when a CActiveRecord instance is created from DB access (model read from DB). At this time, the worklow behavior must be initialized.
| CEvent | event parameter |
Definition at line 709 of file SWActiveRecordBehavior.php.
| afterSave | ( | $ | event | ) |
When option transitionBeforeSave is false, if a task is associated with the transition that was performed, it is executed now, that it after the activeRecord owner component has been saved. The onAfterTransition is also raised.
| SWEvent | $event |
Definition at line 688 of file SWActiveRecordBehavior.php.
| afterTransition | ( | $ | event | ) |
Default implementation for the onAfterTransition event.
This method is dedicated to be overloaded by custom event handler.
| SWEvent | the event parameter |
Definition at line 839 of file SWActiveRecordBehavior.php.
| attach | ( | $ | owner | ) |
Overloads parent attach method so at the time the behavior is about to be attached to the owner component, the behavior is initialized.
During the initialisation, following actions are performed:
Definition at line 190 of file SWActiveRecordBehavior.php.
| beforeSave | ( | $ | event | ) |
Responds to CActiveRecord::onBeforeSave event.
Overrides this method if you want to handle the corresponding event of the owner. You may set CModelEvent::isValid to be false to quit the saving process.
| CModelEvent | event parameter |
Definition at line 655 of file SWActiveRecordBehavior.php.
| beforeTransition | ( | $ | event | ) |
Default implementation for the onBeforeTransition event.
This method is dedicated to be overloaded by custom event handler.
| SWEvent | the event parameter |
Definition at line 795 of file SWActiveRecordBehavior.php.
| canFireEvent | ( | $ | owner, | |
| $ | className | |||
| ) | [protected] |
Checks that the owner component is able to handle workflow events that could be fired by this behavior
| CComponent | $owner the owner component attaching this behavior | |
| string | $className |
Definition at line 106 of file SWActiveRecordBehavior.php.
| enterWorkflow | ( | $ | event | ) |
Default implementation for the onEnterWorkflow event.
This method is dedicated to be overloaded by custom event handler.
| SWEvent | the event parameter |
Definition at line 774 of file SWActiveRecordBehavior.php.
| string name of the class the owner should inherit from in order for SW events | ( | ) |
to be enabled.
Definition at line 612 of file SWActiveRecordBehavior.php.
| finalStatus | ( | $ | event | ) |
Default implementation for the onEnterWorkflow event.
This method is dedicated to be overloaded by custom event handler.
| SWEvent | the event parameter |
Definition at line 863 of file SWActiveRecordBehavior.php.
| initialize | ( | ) | [protected] |
This method is called to initialize the current owner status. If a default workflow can be found and if 'autoInsert' is set to TRUE, the owner component is inserted in the worflow now, by calling swInsertToWorkflow().
| SWException |
Definition at line 218 of file SWActiveRecordBehavior.php.
| onAfterTransition | ( | $ | event | ) |
This event is raised after the onProcessTransition is fired. It is the last event fired during a non-final transition.
Again, in the case of an AR being saved, this event may be fired before or after the record is actually save, depending on the 'transitionBeforeSave' initialization parameters.
| SWEvent | the event parameter |
Definition at line 850 of file SWActiveRecordBehavior.php.
| onBeforeTransition | ( | $ | event | ) |
This event is raised before a workflow transition is applied to the owner instance.
| SWEvent | the event parameter |
Definition at line 803 of file SWActiveRecordBehavior.php.
| onEnterWorkflow | ( | $ | event | ) |
This event is raised after the record instance is inserted into a workflow. This may occur at construction time (new) if the behavior is initialized with autoInsert set to TRUE and in this case, the 'onEnterWorkflow' event is always fired. Consequently, when a model instance is created from database (find), the onEnterWorkflow is fired even if the record has already be inserted in a workflow (e.g contains a valid status).
| SWEvent | the event parameter |
Definition at line 786 of file SWActiveRecordBehavior.php.
| onFinalStatus | ( | $ | event | ) |
This event is raised at the end of a transition, when the destination status is a final status (i.e the owner model has reached a status from where it will not be able to move).
| SWEvent | the event parameter |
Definition at line 873 of file SWActiveRecordBehavior.php.
| onProcessTransition | ( | $ | event | ) |
This event is raised when a workflow transition is in progress. In such case, the user may define a handler for this event in order to run specific process.
Depending on the 'transitionBeforeSave' initialization parameters, this event could be fired before or after the owner model is actually saved to the database. Of course this only applies when status change is initiated when saving the record. A call to swNextStatus() is not affected by the 'transitionBeforeSave' option.
| SWEvent | the event parameter |
Definition at line 825 of file SWActiveRecordBehavior.php.
| processTransition | ( | $ | event | ) |
Default implementation for the onProcessTransition event.
This method is dedicated to be overloaded by custom event handler.
| SWEvent | the event parameter |
Definition at line 812 of file SWActiveRecordBehavior.php.
| swCreateNode | ( | $ | str | ) |
Creates a node from the string passed as argument. If $str doesn't contain a workflow Id, this method uses the workflowId associated with the owner model. The node created here doesn't have to exist within a workflow.
| string | $str string status name |
Definition at line 424 of file SWActiveRecordBehavior.php.
| swGetAllStatus | ( | ) |
Returns all statuses belonging to the workflow the owner component is inserted in. If the owner component is not inserted in a workflow, an empty array is returned.
Definition at line 355 of file SWActiveRecordBehavior.php.
| swGetDefaultWorkflowId | ( | ) |
Finds out what should be the default workflow to use with the owner model. A default workflow id in several ways which are explored by this method, in the following order:
Definition at line 246 of file SWActiveRecordBehavior.php.
| swGetNextStatus | ( | ) |
This method returns a list of nodes that can be actually reached at the time the method is called. To be reachable, a transition must exist between the current status and the next status, AND if a constraint is defined, it must be evaluated to true.
Definition at line 332 of file SWActiveRecordBehavior.php.
| swGetStatus | ( | ) |
If the owner component is inserted into a workflow, this method returns the SWNode object that represent this status, otherwise NULL is returned.
Definition at line 115 of file SWActiveRecordBehavior.php.
| swGetWorkflowId | ( | ) |
Returns the current workflow Id the owner component is inserted in, or NULL if the owner component is not inserted into a workflow.
| string | current workflow Id or NULL |
Definition at line 170 of file SWActiveRecordBehavior.php.
| swHasStatus | ( | ) |
Use this method to find out if the owner component is currently inserted into a workflow. This method is equivalent to swGetStatus()!=null.
Definition at line 130 of file SWActiveRecordBehavior.php.
| swInsertToWorkflow | ( | $ | workflow = null |
) |
Insert the owner component into the workflow whose id is passed as argument. If NULL is passed as argument, the default workflow is used.
| string | workflow Id or NULL. |
| SWException | the owner model is already in a workflow |
Definition at line 302 of file SWActiveRecordBehavior.php.
| swIsEventEnabled | ( | ) |
Definition at line 121 of file SWActiveRecordBehavior.php.
| swIsFinalStatus | ( | $ | status = null |
) |
Test if the status passed as argument a final status. If null is passed as argument tests if the current status of the owner component is a final status. By definition a final status as no outgoing transition to other status.
| status | status to test, or null (will test current status) |
Definition at line 462 of file SWActiveRecordBehavior.php.
| swIsInitialStatus | ( | $ | status = null |
) |
Checks if the status passed as argument, or the current status (if NULL is passed) is the initial status of the corresponding workflow. An exception is raised if the owner model is not in a workflow and if $status is null.
| mixed | $status |
| SWException |
Definition at line 485 of file SWActiveRecordBehavior.php.
| swIsNextStatus | ( | $ | nextStatus | ) |
Checks if the status passed as argument can be reached from the current status. This occurs when
Note that if the owner component is not in a workflow, this method returns true if argument $nextStatus is the initial status for the workflow associated with the owner model. In other words the initial status for a given workflow is considered as the 'next' status, for all component associated to this workflow but not inserted in it. Of course, if a constraint is associated with the initial status, it must be evaluated to true.
| mixed | nextStatus String or SWNode object for the next status |
Definition at line 379 of file SWActiveRecordBehavior.php.
| swNextStatus | ( | $ | nextStatus = null |
) |
| mixed | $nextStatus |
Definition at line 543 of file SWActiveRecordBehavior.php.
| swValidate | ( | $ | attribute, | |
| $ | value | |||
| ) |
Validate the status attribute stored in the owner model. This attribute is valid if :
| string | $attribute status attribute name (by default 'status') | |
| mixed | $value current value of the status attribute provided as a string or a SWNode object |
Definition at line 517 of file SWActiveRecordBehavior.php.
| $autoInsert = true |
Definition at line 51 of file SWActiveRecordBehavior.php.
| $defaultWorkflow = null |
Definition at line 45 of file SWActiveRecordBehavior.php.
| $enableEvent = true |
Definition at line 63 of file SWActiveRecordBehavior.php.
$eventClassName = 'SWActiveRecord' [protected] |
Definition at line 87 of file SWActiveRecordBehavior.php.
| $statusAttribute = 'status' |
Definition at line 38 of file SWActiveRecordBehavior.php.
| $transitionBeforeSave = true |
Definition at line 69 of file SWActiveRecordBehavior.php.
| $workflowSourceComponent = 'swSource' |
Definition at line 56 of file SWActiveRecordBehavior.php.
| const SW_I8N_CATEGORY = 'simpleworkflow' |
Definition at line 90 of file SWActiveRecordBehavior.php.
| const SW_LOG_CATEGORY = 'application.simpleWorkflow' |
Definition at line 89 of file SWActiveRecordBehavior.php.
1.7.1