Skip to content

Instantly share code, notes, and snippets.

@gggeek
Created September 5, 2012 10:12
Show Gist options
  • Save gggeek/3634494 to your computer and use it in GitHub Desktop.
Save gggeek/3634494 to your computer and use it in GitHub Desktop.
eZP 5 content object+node creation exampe - the barebones
<?php
// Nb: we assume that scripts are run from root dir, same as eZP4
/**
* @var \eZ\Publish\API\Container $SC
*/
$SC = require('bootstrap.php');
// Log in as Admin
$repo = $SC->getRepository();
$adminUser = $repo->getUserService()->loadUser( 14 );
$repo->setCurrentUser( $adminUser );
// Create a content
$CTService = $repo->getContentTypeService();
$CType = $CTService->loadContentTypeByIdentifier( "testClass" );
$CService = $repo->getContentService();
$CStruct = $CService->newContentCreateStruct( $CType, "eng-GB" );
$CStruct->setField( "title", "Hello world" );
$LService = $repo->getLocationService();
$LStruct = $LService->newLocationCreateStruct( 2 );
$content = $CService->createContent( $CStruct, array( $LStruct ) );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment