Path

ez components / documentation / api reference / 2009.1rc1 / workflow


eZ Components 2009.1rc1

WorkflowSignalSlotTiein

[ Tutorial ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

Introduction

The WorkflowSignalSlotTiein component allows you to hook into the workflow execution into using the SignalSlot component.

Class overview

ezcWorkflowSignalSlotPlugin
Emits signals for the workflow engine's plugin hooks.

Usage

Connect all signals to the slots provided by an object

This example shows how to connect all signals to the slots provided by an object.

  1. <?php
  2. // Connect signals to slots.
  3. $signals = new ezcSignalCollection;
  4. $receiver = new MyReceiver;
  5. $signals->connect( 'afterExecutionStarted', array( $receiver, 'afterExecutionStarted' ) );
  6. $signals->connect( 'afterExecutionSuspended', array( $receiver, 'afterExecutionSuspended' ) );
  7. $signals->connect( 'afterExecutionResumed', array( $receiver, 'afterExecutionResumed' ) );
  8. $signals->connect( 'afterExecutionCancelled', array( $receiver, 'afterExecutionCancelled' ) );
  9. $signals->connect( 'afterExecutionEnded', array( $receiver, 'afterExecutionEnded' ) );
  10. $signals->connect( 'beforeNodeActivated', array( $receiver, 'beforeNodeActivated' ) );
  11. $signals->connect( 'afterNodeActivated', array( $receiver, 'afterNodeActivated' ) );
  12. $signals->connect( 'afterNodeExecuted', array( $receiver, 'afterNodeExecuted' ) );
  13. $signals->connect( 'afterRolledBackServiceObject', array( $receiver, 'afterRolledBackServiceObject' ) );
  14. $signals->connect( 'afterThreadStarted', array( $receiver, 'afterThreadStarted' ) );
  15. $signals->connect( 'afterThreadEnded', array( $receiver, 'afterThreadEnded' ) );
  16. $signals->connect( 'beforeVariableSet', array( $receiver, 'beforeVariableSet' ) );
  17. $signals->connect( 'afterVariableSet', array( $receiver, 'afterVariableSet' ) );
  18. $signals->connect( 'beforeVariableUnset', array( $receiver, 'beforeVariableUnset' ) );
  19. $signals->connect( 'afterVariableUnset', array( $receiver, 'afterVariableUnset' ) );
  20. // Set up database connection.
  21. $db = ezcDbFactory::create( 'mysql://test@localhost/test' );
  22. // Set up workflow definition storage (database).
  23. $definition = new ezcWorkflowDatabaseDefinitionStorage( $db );
  24. // Load latest version of workflow named "Test".
  25. $workflow = $definition->loadByName( 'Test' );
  26. // Set up database-based workflow executer.
  27. $execution = new ezcWorkflowDatabaseExecution( $db );
  28. // Pass workflow object to workflow executer.
  29. $execution->workflow = $workflow;
  30. // Register SignalSlot workflow engine plugin.
  31. $plugin = new ezcWorkflowSignalSlotPlugin;
  32. $plugin->signals = $signals;
  33. $execution->addPlugin( $plugin );
  34. // Start workflow execution.
  35. $id = $execution->start();
  36. ?>

This is a dummy implementation of the MyReceiver class.

  1. <?php
  2. class MyReceiver
  3. {
  4. public function afterExecutionStarted( ezcWorkflowExecution $execution )
  5. {
  6. }
  7. public function afterExecutionSuspended( ezcWorkflowExecution $execution )
  8. {
  9. }
  10. public function afterExecutionResumed( ezcWorkflowExecution $execution )
  11. {
  12. }
  13. public function afterExecutionCancelled( ezcWorkflowExecution $execution )
  14. {
  15. }
  16. public function afterExecutionEnded( ezcWorkflowExecution $execution )
  17. {
  18. }
  19. public function beforeNodeActivated( ezcWorkflowExecution $execution, ezcWorkflowNode $node, ezcWorkflowSignalSlotReturnValue $return )
  20. {
  21. }
  22. public function afterNodeActivated( ezcWorkflowExecution $execution, ezcWorkflowNode $node )
  23. {
  24. }
  25. public function afterNodeExecuted( ezcWorkflowExecution $execution, ezcWorkflowNode $node )
  26. {
  27. }
  28. public function afterThreadStarted( ezcWorkflowExecution $execution, $threadId, $parentId, $numSiblings )
  29. {
  30. }
  31. public function afterThreadEnded( ezcWorkflowExecution $execution, $threadId )
  32. {
  33. }
  34. public function beforeVariableSet( ezcWorkflowExecution $execution, $variableName, $value, ezcWorkflowSignalSlotReturnValue $return )
  35. {
  36. }
  37. public function afterVariableSet( ezcWorkflowExecution $execution, $variableName, $value )
  38. {
  39. }
  40. public function beforeVariableUnset( ezcWorkflowExecution $execution, $variableName, ezcWorkflowSignalSlotReturnValue $return )
  41. {
  42. }
  43. public function afterVariableUnset( ezcWorkflowExecution $execution, $variableName )
  44. {
  45. }
  46. }
  47. ?>

Slots that receive an ezcWorkflowSignalSlotReturnValue object are special in the way that they can control if and how the current execution step will be performed. For more information on this advice mechanism please refer to the documentation of the workflow engine plugin system.

For more information on using the SignalSlot component please refer to its documentation.

Last updated: Mon, 22 Jun 2009