Created
September 5, 2012 10:13
-
-
Save pspanja/3634511 to your computer and use it in GitHub Desktop.
Create content with location
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @var \eZ\Publish\API\Container $serviceContainer | |
*/ | |
$serviceContainer = require "bootstrap.php"; | |
$repository = $serviceContainer->getRepository(); | |
$administratorUser = $repository->getUserService()->loadUser( 14 ); | |
$repository->setCurrentUser( $administratorUser ); | |
// CREATE CONTENT | |
$contentTypeService = $repository->getContentTypeService(); | |
$contentType = $contentTypeService->loadContentTypeByIdentifier( "project" ); | |
$contentService = $repository->getContentService(); | |
$contentCreate = $contentService->newContentCreateStruct( $contentType, "eng-GB" ); | |
$contentCreate->setField( "title", "eZ Publish" ); | |
$contentCreate->setField( "version", 5 ); | |
$locationCreateStruct = $repository->getLocationService()->newLocationCreateStruct( 2 ); | |
$content = $contentService->createContent( $contentCreate, array( $locationCreateStruct ) ); | |
$contentId = $content->id; | |
$versionNo = $content->contentInfo->currentVersionNo; | |
var_dump( $content, $content->id, $content->contentInfo->currentVersionNo ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment