|
@@ 397-415 (lines=19) @@
|
| 394 |
|
* |
| 395 |
|
* @return \eZ\Publish\Core\REST\Server\Values\CreatedVersion |
| 396 |
|
*/ |
| 397 |
|
public function createDraftFromVersion($contentId, $versionNumber) |
| 398 |
|
{ |
| 399 |
|
$contentInfo = $this->repository->getContentService()->loadContentInfo($contentId); |
| 400 |
|
$contentType = $this->repository->getContentTypeService()->loadContentType($contentInfo->contentTypeId); |
| 401 |
|
$contentDraft = $this->repository->getContentService()->createContentDraft( |
| 402 |
|
$contentInfo, |
| 403 |
|
$this->repository->getContentService()->loadVersionInfo($contentInfo, $versionNumber) |
| 404 |
|
); |
| 405 |
|
|
| 406 |
|
return new Values\CreatedVersion( |
| 407 |
|
array( |
| 408 |
|
'version' => new Values\Version( |
| 409 |
|
$contentDraft, |
| 410 |
|
$contentType, |
| 411 |
|
$this->repository->getContentService()->loadRelations($contentDraft->getVersionInfo()) |
| 412 |
|
), |
| 413 |
|
) |
| 414 |
|
); |
| 415 |
|
} |
| 416 |
|
|
| 417 |
|
/** |
| 418 |
|
* The system creates a new draft version as a copy from the current version. |
|
@@ 426-449 (lines=24) @@
|
| 423 |
|
* |
| 424 |
|
* @return \eZ\Publish\Core\REST\Server\Values\CreatedVersion |
| 425 |
|
*/ |
| 426 |
|
public function createDraftFromCurrentVersion($contentId) |
| 427 |
|
{ |
| 428 |
|
$contentInfo = $this->repository->getContentService()->loadContentInfo($contentId); |
| 429 |
|
$contentType = $this->repository->getContentTypeService()->loadContentType($contentInfo->contentTypeId); |
| 430 |
|
$versionInfo = $this->repository->getContentService()->loadVersionInfo( |
| 431 |
|
$contentInfo |
| 432 |
|
); |
| 433 |
|
|
| 434 |
|
if ($versionInfo->isDraft()) { |
| 435 |
|
throw new ForbiddenException('Current version is already in status DRAFT'); |
| 436 |
|
} |
| 437 |
|
|
| 438 |
|
$contentDraft = $this->repository->getContentService()->createContentDraft($contentInfo); |
| 439 |
|
|
| 440 |
|
return new Values\CreatedVersion( |
| 441 |
|
array( |
| 442 |
|
'version' => new Values\Version( |
| 443 |
|
$contentDraft, |
| 444 |
|
$contentType, |
| 445 |
|
$this->repository->getContentService()->loadRelations($contentDraft->getVersionInfo()) |
| 446 |
|
), |
| 447 |
|
) |
| 448 |
|
); |
| 449 |
|
} |
| 450 |
|
|
| 451 |
|
/** |
| 452 |
|
* A specific draft is updated. |