Zeta Components - high quality PHP components

eZ Components - WorkflowSignalSlotTiein

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 afterExecutionStartedezcWorkflowExecution $execution )
  5.     {
  6.     }
  7.     public function afterExecutionSuspendedezcWorkflowExecution $execution )
  8.     {
  9.     }
  10.     public function afterExecutionResumedezcWorkflowExecution $execution )
  11.     {
  12.     }
  13.     public function afterExecutionCancelledezcWorkflowExecution $execution )
  14.     {
  15.     }
  16.     public function afterExecutionEndedezcWorkflowExecution $execution )
  17.     {
  18.     }
  19.     public function beforeNodeActivatedezcWorkflowExecution $executionezcWorkflowNode $nodeezcWorkflowSignalSlotReturnValue $return )
  20.     {
  21.     }
  22.     public function afterNodeActivatedezcWorkflowExecution $executionezcWorkflowNode $node )
  23.     {
  24.     }
  25.     public function afterNodeExecutedezcWorkflowExecution $executionezcWorkflowNode $node )
  26.     {
  27.     }
  28.     public function afterThreadStartedezcWorkflowExecution $execution$threadId$parentId$numSiblings )
  29.     {
  30.     }
  31.     public function afterThreadEndedezcWorkflowExecution $execution$threadId )
  32.     {
  33.     }
  34.     public function beforeVariableSetezcWorkflowExecution $execution$variableName$valueezcWorkflowSignalSlotReturnValue $return )
  35.     {
  36.     }
  37.     public function afterVariableSetezcWorkflowExecution $execution$variableName$value )
  38.     {
  39.     }
  40.     public function beforeVariableUnsetezcWorkflowExecution $execution$variableNameezcWorkflowSignalSlotReturnValue $return )
  41.     {
  42.     }
  43.     public function afterVariableUnsetezcWorkflowExecution $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.