How To use eZOperationHandler::execute

Author Message

Petr Mrzena

Wednesday 30 April 2003 1:06:38 am

I need to create new object instance and publish it in some existing node. Someone told me to use eZOperationHandler, but when I do so, I get this error:

Warning: Invalid argument supplied for foreach() in c:\program files\ez systems\ezpublish\lib\ezutils\classes\ezmoduleoperationinfo.php on line 82

Is there some extra initialization necessary?

Gunnstein Lye

Friday 02 May 2003 8:11:49 am

Show us the code you use, then it's easier to tell what could be wrong.

Petr Mrzena

Monday 05 May 2003 12:47:54 am

include_once( "kernel/classes/ezcontentclass.php" );
include_once( "kernel/classes/eznodeassignment.php");
include_once( "kernel/content/ezcontentoperationcollection.php" );

$node =& eZContentObjectTreeNode::fetch( 2 );
$parentContentObject =& $node->attribute( 'object' );
$sectionID = $parentContentObject->attribute( 'section_id' );

$class =& eZContentClass::fetch( 1 );
$contentObject =& $class->instantiate( 14, $sectionID );
$contentObject->setName( "MyNewFolder" );

$contentObject->store();

$nodeAssignment =& eZNodeAssignment::create( array(
'contentobject_id' => $contentObject->attribute( 'id' ),
'contentobject_version' => $contentObject->attribute( 'current_version' ),
'parent_node' => $node->attribute( 'node_id' ),
'is_main' => 1
)
);
$nodeAssignment->store();
include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
$operationResult =& eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObject->attribute( 'id' ),
'version' =>1 ) );

$contentObject =& eZContentObject::fetch( $contentObject->attribute( 'id' ) );

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