How to making a new delating trigger?

Author Message

christian bencivenni

Thursday 12 January 2006 8:48:51 am

Hi.
I must modify a DB table when an object is deleted.
I have the workflow ready and the event which will modify the table operative.
What I'm not understand is what I must write in the BODY section of the trigger.
The functions that EZ use to delete an object?
My functions to delete an object?
Nothing?

How can make understandable for my new trigger that it must activate when an object is deleted?

Thanks

christian bencivenni

Friday 13 January 2006 2:32:05 am

I append this lines to operation_definition.php file in kernel/content/:

$OperationList['canceltrigger'] = array (						               'name' => 'canceltrigger',
	               'default_call_method'=> 'kernel/content/ezcontentoperationcollection.php',
	               'class' => 'ezcontentoperationcollection',
	               'parameter_type' => 'standard',
	               'parameters' => array(	
                                 array( 
		 'name' => 'object_id',
		 'type' => 'integer',
		 'required' => true),
	                 array( 
		 'name' => 'version',
		 'type' => 'integer',
		 'required' => true)),
	'keys' => array('object_id'),
	'body' => array(
		array(
			'type' => 'trigger',
			'name' => 'pre_cancel',
			'keys' => array('object_id','version')),
		array(
			'type' => 'method',
			'name' => 'removeOldNodes',
			'frequency' => 'once',
			'method' => 'removeOldNodes' )));

Is it correct?
Then I have an event where modify my personal DB table.
The only deleting function I found is removeOldNodes($idobject, $version) in the ezcontentoperationcollection class.
But when I delete an object from the admin_view nothing appens.
Where is the error?

christian bencivenni

Monday 16 January 2006 1:02:04 am

No one can help me?
Jeez...

Kåre Køhler Høvik

Monday 16 January 2006 1:33:01 am

Hi

You need to add to : kernel/content/removeobject.php

    $operationResult = eZOperationHandler::execute( 'content', 'canceltrigger', array( 'object_id' => $contentObjectID ), null, $useTriggers );

You should also remove version ID from the operation definition.

Override workflow.ini with ( to list it in <eZ_url>/trigger/list ):

[OperationSettings]
AvailableOperations=content_publish;before_shop_confirmorder;shop_checkout;content_canceltrigger

Kåre Høvik

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.