Skip to content

Commit

Permalink
Allowing update of content remote ID
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Clements committed Apr 28, 2016
1 parent 32ad279 commit 0ee0eae
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions Core/API/Managers/ContentManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,28 @@ public function update()
$contentType = $contentTypeService->loadContentType($contentInfo->contentTypeId);
$contentUpdateStruct = $contentService->newContentUpdateStruct();

$this->setFieldsToUpdate($contentUpdateStruct, $this->dsl['attributes'], $contentType);
if (array_key_exists('attributes', $this)) {
$this->setFieldsToUpdate($contentUpdateStruct, $this->dsl['attributes'], $contentType);
}

$draft = $contentService->createContentDraft($contentInfo);
$contentService->updateContent($draft->versionInfo,$contentUpdateStruct);

$content = $contentService->publishVersion($draft->versionInfo);

if (array_key_exists('new_remote_id', $this->dsl)) {
// Update object remote ID
$contentMetaDataUpdateStruct = $contentService->newContentMetadataUpdateStruct();
$contentMetaDataUpdateStruct->remoteId = $this->dsl['new_remote_id'];
$content = $contentService->updateContentMetadata($content->contentInfo, $contentMetaDataUpdateStruct);

// Update main location remote ID
$locationService = $this->repository->getLocationService();
$locationUpdateStruct = $locationService->newLocationUpdateStruct();
$locationUpdateStruct->remoteId = $this->dsl['new_remote_id'] . '_location';
$location = $locationService->loadLocation($content->contentInfo->mainLocationId);
$locationService->updateLocation($location, $locationUpdateStruct);
}

$this->setReferences($content);
}

Expand Down

0 comments on commit 0ee0eae

Please sign in to comment.