|
@@ 23-64 (lines=42) @@
|
| 20 |
|
* |
| 21 |
|
* @return \eZ\Publish\API\Repository\Values\Content\Content |
| 22 |
|
*/ |
| 23 |
|
protected function createContentVersion1EmptyBinaryField() |
| 24 |
|
{ |
| 25 |
|
$repository = $this->getRepository(); |
| 26 |
|
|
| 27 |
|
$parentLocationId = $this->generateId('location', 56); |
| 28 |
|
$sectionId = $this->generateId('section', 1); |
| 29 |
|
/* BEGIN: Inline */ |
| 30 |
|
// $parentLocationId is the id of the /Design/eZ-publish node |
| 31 |
|
|
| 32 |
|
$contentService = $repository->getContentService(); |
| 33 |
|
$contentTypeService = $repository->getContentTypeService(); |
| 34 |
|
$locationService = $repository->getLocationService(); |
| 35 |
|
|
| 36 |
|
// Configure new location |
| 37 |
|
$locationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
| 38 |
|
|
| 39 |
|
$locationCreate->priority = 23; |
| 40 |
|
$locationCreate->hidden = true; |
| 41 |
|
$locationCreate->remoteId = '0123456789abcdef0123456789abcdefgh'; |
| 42 |
|
$locationCreate->sortField = Location::SORT_FIELD_NODE_ID; |
| 43 |
|
$locationCreate->sortOrder = Location::SORT_ORDER_DESC; |
| 44 |
|
|
| 45 |
|
// Load content type |
| 46 |
|
$contentType = $contentTypeService->loadContentTypeByIdentifier('video'); |
| 47 |
|
|
| 48 |
|
// Configure new content object |
| 49 |
|
$contentCreate = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
| 50 |
|
|
| 51 |
|
$contentCreate->setField('name', 'An empty file'); |
| 52 |
|
$contentCreate->remoteId = 'abcdef0123456789abcdef0123456789gh'; |
| 53 |
|
// $sectionId is the ID of section 1 |
| 54 |
|
$contentCreate->sectionId = $sectionId; |
| 55 |
|
$contentCreate->alwaysAvailable = true; |
| 56 |
|
|
| 57 |
|
// Create a draft |
| 58 |
|
$draft = $contentService->createContent($contentCreate, array($locationCreate)); |
| 59 |
|
|
| 60 |
|
$content = $contentService->publishVersion($draft->getVersionInfo()); |
| 61 |
|
/* END: Inline */ |
| 62 |
|
|
| 63 |
|
return $content; |
| 64 |
|
} |
| 65 |
|
|
| 66 |
|
/** |
| 67 |
|
* Creates a fresh clean content draft. |
|
@@ 71-110 (lines=40) @@
|
| 68 |
|
* |
| 69 |
|
* @return \eZ\Publish\API\Repository\Values\Content\Content |
| 70 |
|
*/ |
| 71 |
|
protected function createContentDraftVersion1($locationId = 56, $contentTypeIdentifier = 'forum', $contentFieldNameIdentifier = 'name') |
| 72 |
|
{ |
| 73 |
|
$repository = $this->getRepository(); |
| 74 |
|
|
| 75 |
|
$parentLocationId = $this->generateId('location', $locationId); |
| 76 |
|
$sectionId = $this->generateId('section', 1); |
| 77 |
|
/* BEGIN: Inline */ |
| 78 |
|
// $parentLocationId is the id of the /Design/eZ-publish node |
| 79 |
|
|
| 80 |
|
$contentService = $repository->getContentService(); |
| 81 |
|
$contentTypeService = $repository->getContentTypeService(); |
| 82 |
|
$locationService = $repository->getLocationService(); |
| 83 |
|
|
| 84 |
|
// Configure new location |
| 85 |
|
$locationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
| 86 |
|
|
| 87 |
|
$locationCreate->priority = 23; |
| 88 |
|
$locationCreate->hidden = true; |
| 89 |
|
$locationCreate->remoteId = '0123456789abcdef0123456789abcdef'; |
| 90 |
|
$locationCreate->sortField = Location::SORT_FIELD_NODE_ID; |
| 91 |
|
$locationCreate->sortOrder = Location::SORT_ORDER_DESC; |
| 92 |
|
|
| 93 |
|
// Load content type |
| 94 |
|
$contentType = $contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier); |
| 95 |
|
|
| 96 |
|
// Configure new content object |
| 97 |
|
$contentCreate = $contentService->newContentCreateStruct($contentType, 'eng-US'); |
| 98 |
|
|
| 99 |
|
$contentCreate->setField($contentFieldNameIdentifier, "An awesome {$contentTypeIdentifier}"); |
| 100 |
|
$contentCreate->remoteId = 'abcdef0123456789abcdef0123456789'; |
| 101 |
|
// $sectionId is the ID of section 1 |
| 102 |
|
$contentCreate->sectionId = $sectionId; |
| 103 |
|
$contentCreate->alwaysAvailable = true; |
| 104 |
|
|
| 105 |
|
// Create a draft |
| 106 |
|
$draft = $contentService->createContent($contentCreate, array($locationCreate)); |
| 107 |
|
/* END: Inline */ |
| 108 |
|
|
| 109 |
|
return $draft; |
| 110 |
|
} |
| 111 |
|
|
| 112 |
|
/** |
| 113 |
|
* Creates a fresh clean published content instance. |