How To use eZOperationHandler::execute again ...

Author Message

Petr Mrzena

Tuesday 06 May 2003 6:36:00 am

Sorry for reposting, but it looks like nobody read old messages :(

I asked:
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?

Then somebody asked me for source, so here it is:

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' ) );

Sergiy Pushchin

Friday 09 May 2003 12:39:36 am

If you run that script as shell script or smth. like that i.e. without index.php you need to do some initialization.

// Initialize module loading
include_once( "lib/ezutils/classes/ezmodule.php" );

$moduleINI =& eZINI::instance( 'module.ini' );
$globalModuleRepositories = $moduleINI->variable( 'ModuleSettings', 'ModuleRepositories' );
$extensionRepositories = $moduleINI->variable( 'ModuleSettings', 'ExtensionRepositories' );
$extensionDirectory = eZExtension::baseDirectory();
$globalExtensionRepositories = array();
foreach ( $extensionRepositories as $extensionRepository )
{
$modulePath = $extensionDirectory . '/' . $extensionRepository . '/modules';
if ( file_exists( $modulePath ) )
{
$globalExtensionRepositories[] = $modulePath;
}
}
$moduleRepositories = array_merge( $moduleRepositories, $globalModuleRepositories, $globalExtensionRepositories );
eZModule::setGlobalPathList( $moduleRepositories );

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 11:31:03
Script start
Timing: Jan 18 2025 11:31:03
Module start 'layout'
Timing: Jan 18 2025 11:31:03
Module start 'content'
Timing: Jan 18 2025 11:31:04
Module end 'content'
Timing: Jan 18 2025 11:31:04
Script end

Main resources:

Total runtime0.6728 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0070 594.8359152.6406
Module start 'layout' 0.00700.0035 747.476639.4766
Module start 'content' 0.01050.6609 786.9531507.3047
Module end 'content' 0.67140.0014 1,294.257812.1250
Script end 0.6728  1,306.3828 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.4952160.0002
Check MTime0.00140.2107160.0001
Mysql Total
Database connection0.00080.120710.0008
Mysqli_queries0.620492.2135540.0115
Looping result0.00050.0789520.0000
Template Total0.635094.420.3175
Template load0.00230.339120.0011
Template processing0.632794.044320.3164
Template load and register function0.00030.042210.0003
states
state_id_array0.00120.185210.0012
state_identifier_array0.00110.162420.0005
Override
Cache load0.00200.2931510.0000
Sytem overhead
Fetch class attribute can translate value0.00070.107720.0004
Fetch class attribute name0.00090.132030.0003
XML
Image XML parsing0.00060.089620.0003
class_abstraction
Instantiating content class attribute0.00000.001130.0000
General
dbfile0.00080.1237160.0001
String conversion0.00000.001340.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/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
7content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 21
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs