Workflow Event -> Access to current Object

Author Message

Anita H

Monday 12 January 2009 4:18:39 am

Hi All,

I'm working on an example to insert/update data into sugarCRM based on data (own class) ezPublish. Therefore I created an own eventtype which is connected to the trigger content-publish-before.

The trigger executes my event nicely and the insert into sugarCRM works as well, unfortunately I just do not succeed in fetching the object data currently published. E.g. I'm editing an instance of my class in ezPublish Admin Window and "send to publish" it.

How can I access within my eventtype the object data currently updated? I tried quite a lot and this is my last unsuccessful version:

--code snippet not complete ------------------------------------------------------------------------------
class clixxaccommodationaddtype extends eZWorkflowEventType
{
const WORKFLOW_TYPE_STRING = 'clixxaccommodationadd';

/*!
Constructor
*/
function clixxaccommodationaddtype()
{
$this->eZWorkflowEventType( clixxaccommodationaddtype::WORKFLOW_TYPE_STRING, ezi18n( 'clixxezsugarcrm/eventtypes/event', "clixx Accommodation Add" ) );
$this->setTriggerTypes( array( 'content' => array( 'publish' => array( 'before',
'after' ) ) ) );
}

function execute( $process, $event )
{
$ini = eZINI::instance( 'workflow.ini.append.php' );


/*
The data array that should be sent together with this functions can hold:

clixxid *
name *
type
url

* Variables with * is required

*/

//Set local variables
$v = array();
$http =& eZHTTPTool::instance();
$data = $process->attribute( 'parameter_list' );

$object =& eZContentObject::fetch( $data['object_id'] );


// Load settings
$time = new eZDateTime();
$ini =& eZINI::instance( "clixxezsugarcrm.ini" );

$v['sugarcrm_register_user'] = $ini->variable( 'SugarUser', 'RegisterUserID');
$v['unique_id'] = $http->getSessionKey() . $time->currentTimeStamp();

//log
$log = $ini->variable( 'Accommodation', 'Log');
$logFile = $ini->variable( 'Accommodation', 'LogFile');
$logDir = $ini->variable( 'Accommodation', 'LogDirectory');

$processParams = unserialize( $process->Parameters );
$object_id = $processParams['object_id'];
$object = eZContentObject::fetch($object_id);

$contentObjectAttributes =& $object->contentObjectAttributes();

if (is_string($log)) {
eZLog::write( 'process: '.$process, $logFile, $logDir);
eZLog::write( 'event: '.$event, $logFile, $logDir);
eZLog::write ( 'accommodation dbWrite started', $logFile, $logDir);
eZLog::write ( 'parameter name: '.$data['name'], $logFile, $logDir);
eZLog::write ( 'object_id: '.$object, $logFile, $logDir);
eZLog::write( var_export($contentObjectAttribute), $logFile, $logDir);
}

-- End code snippet ------------------------------------------------------------------------------------------

The problem is that $process, $event as well as $contentObjectAttribute are always empty and I cannot access the object data....

More than happy to get help....
Thanks a lot
Anita

Anita H

Monday 12 January 2009 7:26:45 am

Hi All,
changed the relevant part to:

$processParameters = $process->attribute( 'parameter_list' );
$object_id = $processParameters['object_id'];
$object = eZContentObject::fetch($object_id);

$contentObjectAttributes =& $object->contentObjectAttributes();
$object_name= $object->attribute('name');

and this seems to work.
Thanks anyway.
Anita

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

eZ debug

Timing: Jan 18 2025 19:13:14
Script start
Timing: Jan 18 2025 19:13:14
Module start 'layout'
Timing: Jan 18 2025 19:13:14
Module start 'content'
Timing: Jan 18 2025 19:13:15
Module end 'content'
Timing: Jan 18 2025 19:13:15
Script end

Main resources:

Total runtime0.7478 sec
Peak memory usage4,096.0000 KB
Database Queries52

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 588.0313152.6406
Module start 'layout' 0.00560.0044 740.671939.4766
Module start 'content' 0.01000.7362 780.1484488.1719
Module end 'content' 0.74620.0015 1,268.320312.1250
Script end 0.7477  1,280.4453 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00360.4849160.0002
Check MTime0.00140.1874160.0001
Mysql Total
Database connection0.00080.113010.0008
Mysqli_queries0.674690.2108520.0130
Looping result0.00050.0708500.0000
Template Total0.703094.020.3515
Template load0.00210.278220.0010
Template processing0.700993.734520.3505
Template load and register function0.00010.016610.0001
states
state_id_array0.00080.104210.0008
state_identifier_array0.00210.276420.0010
Override
Cache load0.00190.2519780.0000
Sytem overhead
Fetch class attribute can translate value0.00060.084510.0006
Fetch class attribute name0.00170.232830.0006
XML
Image XML parsing0.00170.232010.0017
class_abstraction
Instantiating content class attribute0.00000.001840.0000
General
dbfile0.00720.9659160.0005
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
16content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
15content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 37
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs