Wednesday 14 July 2010 9:35:08 am
I can't be sure as I am fairly new to dabbling in the eZ API but this might help. There was an extra ',' in your first array. Also when accessing attributes of a node or object, I think it's standard practice to use:
$object->attribute('node_id'); Also, it's best to check the object or node to see if it is set or empty before looping over it. I added some log writes. I would have typed them in French but it is quite rusty. Good luck! Lastly, try looking at the kernel code, that is usually the best way to find out about standards for now until the API is more completely documented. (crosses fringers)
$paramsDelete = array(
'ClassFilterType' => 'include',
'ClassFilterArray' => array ( $params['class_identifier'] ),
'Offset' => 0,
'MainNodeOnly' => true
);
$testsDelete = eZContentObjectTreeNode::subTreeByNodeID( $paramsDelete, 2 );
$log->write( 'Nb objets tests a supprimer: '.count($testsDelete), 'psychoTestImport.log', $logFolder);
if ( isset( $testsDelete ) )
{
foreach( $testsDelete as $test )
{
$cli->output( " ACTION: suppression du test " . $test->attribute('object_id') );
$contentObject = eZContentObject::fetch( $test->attribute('object_id' );
if ( isset( $contentObject ) )
{
foreach( $contentObject->attribute( 'assigned_nodes' ) as $assignedNode ){
$cli->output( " ACTION: suppression du noeud ".$assignedNode->attribute('node_id')." du test".$test->ContentObjectID );
eZContentObjectTreeNode::removeNode( $assignedNode->attribute('node_id') );
$cptDel++;
}
$cptDelNodes += count($contentObject->attribute( 'assigned_nodes' ));
$cptDelObjs++;
$contentObject->purge();
}
else
{
$log->write( 'Failed to fetch object for deletion.', 'psychoTestImport.log', $logFolder );
}
}
}
else
{
$log->write( 'Failed to fetch parent objects.', 'psychoTestImport.log', $logFolder);
}
Brandon Chambers
brandon@granitehorizon.com
blog: http://blog.divdesigns.com
Granite Horizon / http://granitehorizon.com
|