Builds a VersionInfo domain object from value object returned from persistence.
public buildVersionInfoDomainObject ( eZ\Publish\SPI\Persistence\Content\VersionInfo $spiVersionInfo ) : |
||
$spiVersionInfo | eZ\Publish\SPI\Persistence\Content\VersionInfo | |
리턴 |
/** * Copies the content to a new location. If no version is given, * all versions are copied, otherwise only the given version. * * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to copy the content to the given location * * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct $destinationLocationCreateStruct the target location where the content is copied to * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo * * @return \eZ\Publish\API\Repository\Values\Content\Content */ public function copyContent(ContentInfo $contentInfo, LocationCreateStruct $destinationLocationCreateStruct, APIVersionInfo $versionInfo = null) { if (!$this->repository->canUser('content', 'create', $contentInfo, $destinationLocationCreateStruct)) { throw new UnauthorizedException('content', 'create', array('parentLocationId' => $destinationLocationCreateStruct->parentLocationId, 'sectionId' => $contentInfo->sectionId)); } $defaultObjectStates = $this->getDefaultObjectStates(); $this->repository->beginTransaction(); try { $spiContent = $this->persistenceHandler->contentHandler()->copy($contentInfo->id, $versionInfo ? $versionInfo->versionNo : null); foreach ($defaultObjectStates as $objectStateGroupId => $objectState) { $this->persistenceHandler->objectStateHandler()->setContentState($spiContent->versionInfo->contentInfo->id, $objectStateGroupId, $objectState->id); } $content = $this->internalPublishVersion($this->domainMapper->buildVersionInfoDomainObject($spiContent->versionInfo), $spiContent->versionInfo->creationDate); $this->repository->getLocationService()->createLocation($content->getVersionInfo()->getContentInfo(), $destinationLocationCreateStruct); $this->repository->commit(); } catch (Exception $e) { $this->repository->rollback(); throw $e; } return $this->internalLoadContent($content->id); }