Monday 21 March 2005 2:33:58 am
Heres a small example of a adding a trigger The key is to add your trigger to the operation_definition.php file within a module. For example to add a trigger to the user module (which has no triggers) add: kernel/user/operation_definition.php
$OperationList = array();
$OperationList['activate'] = array( 'name' => 'activate',
'default_call_method' => array( 'include_file' => 'kernel/user/ezuseroperationcollection.php',
'class' => 'eZUserOperationCollection' ),
'parameter_type' => 'standard',
'parameters' => array( array( 'name' => 'user_id',
'type' => 'integer',
'required' => true ),
),
'keys' => array( 'user_id' ),
'body' => array( array( 'type' => 'trigger',
'name' => 'post_activate',
'keys' => array( 'user_id' ) )));
?>
This adds a trigger to the activate function which will run when the user confirms their intention to register. To make the activate.php file respect the trigger you need to add the following code: kernel/user/activate.php
//Run workflow
include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
$operationResult = eZOperationHandler::execute( 'user','activate', array( 'user_id' => $userID ) );
And note in this example the presence of another class, which isnt used but might need to be present. Its ok for it to be empty. kernel/user/ezuseroperationcollection.php
<?php
?>
The last part is to active your trigger. In workflow.ini add the trigger to the operation settings:
[OperationSettings]
AvailableOperations=content_publish;shop_confirmorder;shop_checkout;user_activate
Once cache is cleared the trigger should show up in the trigger area. In general these triggers and handlers will have been set up for you in the main modules. Have a look at other 'operation' files to get the general idea. Hope this helps Paul
|