|
@@ 422-440 (lines=19) @@
|
| 419 |
|
* |
| 420 |
|
* @return \eZ\Publish\Core\REST\Server\Values\CreatedVersion |
| 421 |
|
*/ |
| 422 |
|
public function createDraftFromVersion($contentId, $versionNumber) |
| 423 |
|
{ |
| 424 |
|
$contentInfo = $this->repository->getContentService()->loadContentInfo($contentId); |
| 425 |
|
$contentType = $this->repository->getContentTypeService()->loadContentType($contentInfo->contentTypeId); |
| 426 |
|
$contentDraft = $this->repository->getContentService()->createContentDraft( |
| 427 |
|
$contentInfo, |
| 428 |
|
$this->repository->getContentService()->loadVersionInfo($contentInfo, $versionNumber) |
| 429 |
|
); |
| 430 |
|
|
| 431 |
|
return new Values\CreatedVersion( |
| 432 |
|
array( |
| 433 |
|
'version' => new Values\Version( |
| 434 |
|
$contentDraft, |
| 435 |
|
$contentType, |
| 436 |
|
$this->repository->getContentService()->loadRelations($contentDraft->getVersionInfo()) |
| 437 |
|
), |
| 438 |
|
) |
| 439 |
|
); |
| 440 |
|
} |
| 441 |
|
|
| 442 |
|
/** |
| 443 |
|
* The system creates a new draft version as a copy from the current version. |
|
@@ 451-474 (lines=24) @@
|
| 448 |
|
* |
| 449 |
|
* @return \eZ\Publish\Core\REST\Server\Values\CreatedVersion |
| 450 |
|
*/ |
| 451 |
|
public function createDraftFromCurrentVersion($contentId) |
| 452 |
|
{ |
| 453 |
|
$contentInfo = $this->repository->getContentService()->loadContentInfo($contentId); |
| 454 |
|
$contentType = $this->repository->getContentTypeService()->loadContentType($contentInfo->contentTypeId); |
| 455 |
|
$versionInfo = $this->repository->getContentService()->loadVersionInfo( |
| 456 |
|
$contentInfo |
| 457 |
|
); |
| 458 |
|
|
| 459 |
|
if ($versionInfo->isDraft()) { |
| 460 |
|
throw new ForbiddenException('Current version is already in status DRAFT'); |
| 461 |
|
} |
| 462 |
|
|
| 463 |
|
$contentDraft = $this->repository->getContentService()->createContentDraft($contentInfo); |
| 464 |
|
|
| 465 |
|
return new Values\CreatedVersion( |
| 466 |
|
array( |
| 467 |
|
'version' => new Values\Version( |
| 468 |
|
$contentDraft, |
| 469 |
|
$contentType, |
| 470 |
|
$this->repository->getContentService()->loadRelations($contentDraft->getVersionInfo()) |
| 471 |
|
), |
| 472 |
|
) |
| 473 |
|
); |
| 474 |
|
} |
| 475 |
|
|
| 476 |
|
/** |
| 477 |
|
* A specific draft is updated. |