Snippets for eZ publish 3: Creating new content object versions with PHP

This is compatible with eZ Publish 3.

You can update objects by creating new version and publish the new version.

The code

Known variables

  • $object, instance of class eZContentObject


$newVersion =& $object->createNewVersion();
$newData =& $object->fetchDataMap( $newVersion->attribute( 'version' ) );
// change attributes of new version here, by using $newData data map
include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
$result = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $object->attribute( 'id' ), 'version' => $newVersion->attribute( 'version' ) ) );