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.